From f7d876aec664b0884ecb1c157b373de3cdb83471 Mon Sep 17 00:00:00 2001 From: Eliot Berriot <contact@eliotberriot.com> Date: Mon, 8 Jan 2018 23:12:45 +0100 Subject: [PATCH] First store tests \o/ :party: --- front/test/unit/specs/store/auth.spec.js | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 front/test/unit/specs/store/auth.spec.js diff --git a/front/test/unit/specs/store/auth.spec.js b/front/test/unit/specs/store/auth.spec.js new file mode 100644 index 00000000..6ef558f6 --- /dev/null +++ b/front/test/unit/specs/store/auth.spec.js @@ -0,0 +1,52 @@ +import store from '@/store/player' + +describe('mutations', () => { + it('set volume', () => { + // mock state + const state = { volume: 0 } + // apply mutation + store.mutations.volume(state, 0.9) + // assert result + expect(state.volume).to.equal(0.9) + }) + it('set volume max 1', () => { + // mock state + const state = { volume: 0 } + // apply mutation + store.mutations.volume(state, 2) + // assert result + expect(state.volume).to.equal(1) + }) + it('set volume min to 0', () => { + // mock state + const state = { volume: 0.5 } + // apply mutation + store.mutations.volume(state, -2) + // assert result + expect(state.volume).to.equal(0) + }) + it('increment volume', () => { + // mock state + const state = { volume: 0 } + // apply mutation + store.mutations.incrementVolume(state, 0.1) + // assert result + expect(state.volume).to.equal(0.1) + }) + it('increment volume max 1', () => { + // mock state + const state = { volume: 0 } + // apply mutation + store.mutations.incrementVolume(state, 2) + // assert result + expect(state.volume).to.equal(1) + }) + it('increment volume min to 0', () => { + // mock state + const state = { volume: 0.5 } + // apply mutation + store.mutations.incrementVolume(state, -2) + // assert result + expect(state.volume).to.equal(0) + }) +}) -- GitLab