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 { preferenceStore } from '../../stores';
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-03-28 13:38:14 +00:00
|
|
|
const user = { id: 0 };
|
|
|
|
const preferences = {
|
2016-06-25 16:05:24 +00:00
|
|
|
volume: 8,
|
|
|
|
notify: false,
|
2015-12-13 04:42:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
describe('stores/preference', () => {
|
2016-06-25 16:05:24 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
localStorage.set(`preferences_${user.id}`, preferences);
|
|
|
|
preferenceStore.init(user);
|
|
|
|
});
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
describe("#set", () => {
|
|
|
|
it('correctly sets preferences', () => {
|
|
|
|
preferenceStore.set('volume', 5);
|
|
|
|
localStorage.get(`preferences_${user.id}`).volume.should.equal(5);
|
2016-04-05 09:19:20 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
// Test the proxy
|
|
|
|
preferenceStore.volume = 6;
|
|
|
|
localStorage.get(`preferences_${user.id}`).volume.should.equal(6);
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
2016-06-25 16:05:24 +00:00
|
|
|
});
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
describe("#get", () => {
|
|
|
|
it('returns correct preference values', () => {
|
|
|
|
preferenceStore.get('volume').should.equal(8);
|
2016-04-05 09:19:20 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
// Test the proxy
|
|
|
|
preferenceStore.volume.should.equal(8);
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|
2016-06-25 16:05:24 +00:00
|
|
|
});
|
2015-12-13 04:42:28 +00:00
|
|
|
});
|