A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
6 years ago
|
import MemoryStorage from 'background/infrastructures/MemoryStorage';
|
||
7 years ago
|
|
||
|
describe("background/infrastructures/memory-storage", () => {
|
||
|
it('stores values', () => {
|
||
|
let cache = new MemoryStorage();
|
||
|
cache.set('number', 123);
|
||
|
expect(cache.get('number')).to.equal(123);
|
||
|
|
||
|
cache.set('string', '123');
|
||
|
expect(cache.get('string')).to.equal('123');
|
||
|
|
||
|
cache.set('object', { hello: '123' });
|
||
|
expect(cache.get('object')).to.deep.equal({ hello: '123' });
|
||
|
});
|
||
|
|
||
7 years ago
|
it('returns undefined if no keys', () => {
|
||
|
let cache = new MemoryStorage();
|
||
|
expect(cache.get('no-keys')).to.be.undefined;
|
||
|
})
|
||
|
|
||
7 years ago
|
it('stored on shared memory', () => {
|
||
|
let cache = new MemoryStorage();
|
||
|
cache.set('red', 'apple');
|
||
|
|
||
|
cache = new MemoryStorage();
|
||
|
let got = cache.get('red');
|
||
|
expect(got).to.equal('apple');
|
||
|
});
|
||
|
|
||
|
it('stored cloned objects', () => {
|
||
|
let cache = new MemoryStorage();
|
||
|
let recipe = { sugar: '300g' };
|
||
|
cache.set('recipe', recipe);
|
||
|
|
||
|
recipe.salt = '20g'
|
||
|
let got = cache.get('recipe', recipe);
|
||
|
expect(got).to.deep.equal({ sugar: '300g' });
|
||
|
});
|
||
|
|
||
|
it('throws an error with unserializable objects', () => {
|
||
|
let cache = new MemoryStorage();
|
||
|
expect(() => cache.set('fn', setTimeout)).to.throw();
|
||
|
})
|
||
|
});
|