mirror of https://github.com/moparisthebest/mail
added error handling in lawnchair dao
This commit is contained in:
parent
5c1b89dfc9
commit
eaddd674b9
|
@ -2,61 +2,61 @@ module("Lawnchair DAO");
|
||||||
|
|
||||||
var lawnchairdao_test = {};
|
var lawnchairdao_test = {};
|
||||||
|
|
||||||
asyncTest("Init", 2, function() {
|
asyncTest("Init", 2, function() {
|
||||||
// init dependencies
|
// init dependencies
|
||||||
lawnchairdao_test.jsonDao = new app.dao.LawnchairDAO(window);
|
lawnchairdao_test.jsonDao = new app.dao.LawnchairDAO(window);
|
||||||
ok(lawnchairdao_test.jsonDao, 'LanwchairDAO');
|
ok(lawnchairdao_test.jsonDao, 'LanwchairDAO');
|
||||||
|
|
||||||
// clear db before test
|
// clear db before test
|
||||||
lawnchairdao_test.jsonDao.clear(function() {
|
lawnchairdao_test.jsonDao.clear(function() {
|
||||||
ok(true, 'cleared db');
|
ok(true, 'cleared db');
|
||||||
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
asyncTest("CRUD object literal", 4, function() {
|
asyncTest("CRUD object literal", 4, function() {
|
||||||
|
|
||||||
var key = 'type_asdf';
|
var key = 'type_asdf';
|
||||||
var data = {
|
var data = {
|
||||||
name : 'testName',
|
name: 'testName',
|
||||||
type : 'testType'
|
type: 'testType'
|
||||||
};
|
};
|
||||||
|
|
||||||
// create
|
// create
|
||||||
lawnchairdao_test.jsonDao.persist(key, data, function() {
|
lawnchairdao_test.jsonDao.persist(key, data, function() {
|
||||||
|
|
||||||
// read
|
// read
|
||||||
lawnchairdao_test.jsonDao.read(key, function(read) {
|
lawnchairdao_test.jsonDao.read(key, function(read) {
|
||||||
equal(data.name, read.name, 'Create, Read');
|
equal(data.name, read.name, 'Create, Read');
|
||||||
|
|
||||||
// list all
|
// list all
|
||||||
lawnchairdao_test.jsonDao.list('type',0 ,null, function(list) {
|
lawnchairdao_test.jsonDao.list('type', 0, null, function(list) {
|
||||||
ok(list.length === 1, 'List');
|
ok(list.length === 1, 'List');
|
||||||
|
|
||||||
// update
|
// update
|
||||||
var newName = 'updatedName';
|
var newName = 'updatedName';
|
||||||
read.name = newName;
|
read.name = newName;
|
||||||
lawnchairdao_test.jsonDao.persist(key, read, function() {
|
lawnchairdao_test.jsonDao.persist(key, read, function() {
|
||||||
|
|
||||||
// read again
|
// read again
|
||||||
lawnchairdao_test.jsonDao.read(key, function(updated) {
|
lawnchairdao_test.jsonDao.read(key, function(updated) {
|
||||||
equal(updated.name, newName, 'Update');
|
equal(updated.name, newName, 'Update');
|
||||||
|
|
||||||
// delete
|
// delete
|
||||||
lawnchairdao_test.jsonDao.remove(key, function() {
|
lawnchairdao_test.jsonDao.remove(key, function() {
|
||||||
|
|
||||||
// should read empty
|
// should read empty
|
||||||
lawnchairdao_test.jsonDao.read(key, function(lastRead) {
|
lawnchairdao_test.jsonDao.read(key, function(lastRead) {
|
||||||
equal(lastRead, null, 'Delete');
|
equal(lastRead, null, 'Delete');
|
||||||
|
|
||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Reference in New Issue