2016-11-26 03:25:35 +00:00
|
|
|
require('chai').should()
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
import localStorage from 'local-storage'
|
|
|
|
import { preferenceStore } from '../../stores'
|
2015-12-13 04:42:28 +00:00
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
const user = { id: 0 }
|
2016-03-28 13:38:14 +00:00
|
|
|
const preferences = {
|
2016-06-25 16:05:24 +00:00
|
|
|
volume: 8,
|
2016-11-26 03:25:35 +00:00
|
|
|
notify: false
|
|
|
|
}
|
2015-12-13 04:42:28 +00:00
|
|
|
|
|
|
|
describe('stores/preference', () => {
|
2016-06-25 16:05:24 +00:00
|
|
|
beforeEach(() => {
|
2016-11-26 03:25:35 +00:00
|
|
|
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', () => {
|
2016-11-26 03:25:35 +00:00
|
|
|
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
|
2016-11-26 03:25:35 +00:00
|
|
|
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
|
|
|
describe("#get", () => {
|
|
|
|
it('returns correct preference values', () => {
|
2016-11-26 03:25:35 +00:00
|
|
|
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
|
2016-11-26 03:25:35 +00:00
|
|
|
preferenceStore.volume.should.equal(8)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|