From 821413607a0718156f9d25d895e89b1c3d37aa8b Mon Sep 17 00:00:00 2001 From: Daniel Narvaez Date: Wed, 06 Feb 2013 13:49:14 +0000 Subject: Copy various bits from gaia --- (limited to 'apps/system/test/unit/mock_asyncStorage.js') diff --git a/apps/system/test/unit/mock_asyncStorage.js b/apps/system/test/unit/mock_asyncStorage.js new file mode 100644 index 0000000..a657e8b --- /dev/null +++ b/apps/system/test/unit/mock_asyncStorage.js @@ -0,0 +1,36 @@ +'use strict'; + +var MockasyncStorage = { + mItems: {}, + + setItem: function(key, value, callback) { + this.mItems[key] = value; + if (typeof callback === 'function') { + callback(); + } + }, + + getItem: function(key, callback) { + var value = this.mItems[key]; + // use '|| null' will turn a 'false' to null + if (value === undefined) + value = null; + if (typeof callback === 'function') { + callback(value); + } + }, + + removeItem: function(key, callback) { + if (key in this.mItems) { + delete this.mItems[key]; + } + + if (typeof callback === 'function') { + callback(); + } + }, + + mTeardown: function() { + this.mItems = {}; + } +}; -- cgit v0.9.1