1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-25 10:22:18 -05:00
mail/test/unit/localstorage-dao-test.js

36 lines
677 B
JavaScript
Raw Normal View History

2013-03-13 11:58:46 -04:00
module("LocalStorage DAO");
test("CRUD object literal", 4, function() {
var dao = new app.dao.LocalStorageDAO(window);
// clear before test
dao.clear();
var key = 'type_asdf';
var data = {
name : 'testName',
type : 'testType'
};
// create
dao.persist(key, data);
// read
var read = dao.read(key);
equal(data.name, read.name, 'Create, Read');
// list all
var list = dao.list('type');
ok(list.length === 1, 'List');
// update
var newName = 'updatedName';
read.name = newName;
dao.persist(key, read);
var updated = dao.read(key);
equal(updated.name, newName, 'Update');
// delete
dao.remove(key);
equal(dao.read(key), null, 'Delete');
});