29 lines
673 B
JavaScript
29 lines
673 B
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
var assert = require('assert')
|
|
, localStorage = require('localStorage')
|
|
, JsonStorage = require('json-storage')
|
|
, db = JsonStorage(localStorage)
|
|
;
|
|
|
|
assert.strictEqual(null, db.get('a'));
|
|
|
|
// you can't really save undefined as JSON, it's not valid
|
|
// the attempt to do so will delete the underlying key
|
|
db.set('a');
|
|
assert.strictEqual(null, db.get('a'));
|
|
|
|
db.set('a', 1);
|
|
assert.strictEqual(1, db.get('a'));
|
|
|
|
db.set('a', '1');
|
|
assert.strictEqual('1', db.get('a'));
|
|
|
|
db.set('a', [1]);
|
|
assert.deepEqual([1], db.get('a'));
|
|
|
|
db.set('a', { 'a': [1] });
|
|
assert.deepEqual({'a': [1] }, db.get('a'));
|
|
}());
|