koel/resources/assets/js/tests/services/lsTest.js

35 lines
1,001 B
JavaScript
Raw Normal View History

2015-12-13 04:42:28 +00:00
require('chai').should();
import localStorage from 'local-storage';
2016-06-25 10:15:57 +00:00
import { ls } from '../../services';
2015-12-13 04:42:28 +00:00
describe('services/ls', () => {
2015-12-14 13:13:12 +00:00
beforeEach(() => localStorage.remove('foo'));
2015-12-13 04:42:28 +00:00
describe('#get', () => {
it('correctly gets an existing item from local storage', () => {
localStorage('foo', 'bar');
ls.get('foo').should.equal('bar');
});
it('correctly returns the default value for a non exising item', () => {
ls.get('baz', 'qux').should.equal('qux');
});
});
describe('#set', () => {
it('correctly sets an item into local storage', () => {
ls.set('foo', 'bar');
localStorage('foo').should.equal('bar');
});
});
describe('#remove', () => {
it('correctly removes an item from local storage', () => {
localStorage('foo', 'bar');
ls.remove('foo');
(localStorage('foo') === null).should.be.true;
});
});
});