From 9a7e87d33e0c402a39e0fbe2e7a95d97e4c013ec Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Fri, 31 May 2013 13:05:12 +0200 Subject: [PATCH] deleted local storage dao code and tests --- src/js/dao/localstorage-dao.js | 55 ------------------------------ test/integration/index.html | 1 - test/unit/index.html | 2 -- test/unit/localstorage-dao-test.js | 36 ------------------- 4 files changed, 94 deletions(-) delete mode 100644 src/js/dao/localstorage-dao.js delete mode 100644 test/unit/localstorage-dao-test.js diff --git a/src/js/dao/localstorage-dao.js b/src/js/dao/localstorage-dao.js deleted file mode 100644 index d923d91..0000000 --- a/src/js/dao/localstorage-dao.js +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Handles generic caching of JSON objects in LocalStorage - */ -app.dao.LocalStorageDAO = function(window) { - 'use strict'; - - /** - * Stringifies an object literal to JSON and perists it - */ - this.persist = function(key, object) { - var json = JSON.stringify(object); - window.localStorage.setItem(key, json); - }; - - /** - * Fetches a json string from local storage by its key and parses it to an object literal - */ - this.read = function(key) { - var json = window.localStorage.getItem(key); - return JSON.parse(json); - }; - - /** - * List all the items of a certain type in local storage - * @param type [String] The type of item e.g. 'email' - */ - this.list = function(type) { - var i, key, json, list = []; - - for (i = 0; i < window.localStorage.length; i++) { - key = window.localStorage.key(i); - if (key.indexOf(type) === 0) { - json = window.localStorage.getItem(key); - list.push(JSON.parse(json)); - } - } - - return list; - }; - - /** - * Removes an object liter from local storage by its key (delete) - */ - this.remove = function(key) { - window.localStorage.removeItem(key); - }; - - /** - * Clears the whole local storage cache - */ - this.clear = function() { - window.localStorage.clear(); - }; - -}; \ No newline at end of file diff --git a/test/integration/index.html b/test/integration/index.html index 60fe68a..3a02c10 100644 --- a/test/integration/index.html +++ b/test/integration/index.html @@ -45,7 +45,6 @@ - diff --git a/test/unit/index.html b/test/unit/index.html index beca018..e4d16e2 100644 --- a/test/unit/index.html +++ b/test/unit/index.html @@ -45,7 +45,6 @@ - @@ -57,7 +56,6 @@ - diff --git a/test/unit/localstorage-dao-test.js b/test/unit/localstorage-dao-test.js deleted file mode 100644 index e031ef4..0000000 --- a/test/unit/localstorage-dao-test.js +++ /dev/null @@ -1,36 +0,0 @@ -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'); -}); \ No newline at end of file