Skip to content

Commit 8b76481

Browse files
committed
updated tests to match
1 parent 6186e2f commit 8b76481

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ For detailed explanation on how things work, check out [Nuxt.js docs](https://nu
2929
## Test Coverage
3030
| Statements | Branches | Functions | Lines |
3131
| ------------------------- | ----------------------- | ------------------------ | -------------------- |
32-
| ![Statements](https://img.shields.io/badge/Coverage-73.79%25-red.svg) | ![Branches](https://img.shields.io/badge/Coverage-77.78%25-red.svg) | ![Functions](https://img.shields.io/badge/Coverage-74.44%25-red.svg) | ![Lines](https://img.shields.io/badge/Coverage-73.47%25-red.svg) |
32+
| ![Statements](https://img.shields.io/badge/Coverage-72.97%25-red.svg) | ![Branches](https://img.shields.io/badge/Coverage-75.86%25-red.svg) | ![Functions](https://img.shields.io/badge/Coverage-73.4%25-red.svg) | ![Lines](https://img.shields.io/badge/Coverage-72.66%25-red.svg) |

store/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const defaultState = () => ({
3030
currentTimeboxId: -1,
3131
status: statusEnum.STOPPED,
3232
repeat: true,
33-
pauseBetweenTimeboxes: true,
33+
pauseBetweenTimeboxes: false,
3434
remainingTime: 0,
3535
timeboxList: [],
3636
toAddId: 4 // Increment every time a timebox is added to prevent id collision

tests/unit/components/StatusButtons.spec.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ describe("StatusButtons.vue", () => {
8484
);
8585
});
8686

87-
test("stopTimebox() Method", () => {
87+
test("switchStatus() Method", () => {
8888
store.modules.timebox.state.status = statusEnum.STARTED;
89+
store.modules.alarm.state.isPlaying = true;
8990
let setStatusSpy = jest.spyOn(
9091
store.modules.timebox.mutations,
9192
"SET_STATUS"
@@ -97,7 +98,7 @@ describe("StatusButtons.vue", () => {
9798
let wrapper = mount(StatusButtons, {
9899
store: new Vuex.Store(store)
99100
});
100-
wrapper.vm.stopTimebox();
101+
wrapper.vm.switchStatus();
101102
expect(setStatusSpy).toHaveBeenCalled();
102103
expect(audioPauseSpy).toHaveBeenCalled();
103104

@@ -107,7 +108,7 @@ describe("StatusButtons.vue", () => {
107108
wrapper = mount(StatusButtons, {
108109
store: new Vuex.Store(store)
109110
});
110-
wrapper.vm.stopTimebox();
111+
wrapper.vm.switchStatus();
111112
expect(setStatusSpy).toHaveBeenCalled();
112113
expect(audioPauseSpy).not.toHaveBeenCalled();
113114
});

tests/unit/components/TimeboxCard.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Vue from "vue";
22
import Vuetify from "vuetify";
33
Vue.use(Vuetify);
44

5-
import { createLocalVue, shallowMount } from "@vue/test-utils";
5+
import { createLocalVue, mount, shallowMount } from "@vue/test-utils";
66
import Vuex from "vuex";
77

88
import { state, getters, mutations, actions } from "~/store/timebox";
@@ -51,7 +51,7 @@ describe("TimeboxCard.vue", () => {
5151
localVue.use(Vuex);
5252
const store = new Vuex.Store(generateStore());
5353

54-
const wrapper = shallowMount(TimeboxCard, {
54+
const wrapper = mount(TimeboxCard, {
5555
propsData: {
5656
id: 0,
5757
title: "Test Title",

tests/unit/store/alarm.spec.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ describe("alarm/mutations", () => {
5858
});
5959
describe("alarm/actions", () => {
6060
describe("setAlarmAudio", () => {
61+
const rootState = {
62+
timebox: {
63+
pauseBetweenTimeboxes: false
64+
}
65+
};
6166
const state = {
6267
audioObject: null
6368
};
@@ -72,7 +77,7 @@ describe("alarm/actions", () => {
7277
let audioOnEndSpy;
7378

7479
test("Sets audioObject and its event listeners", () => {
75-
actions.setAlarmAudio({ state, commit });
80+
actions.setAlarmAudio({ rootState, state, commit });
7681
expect(commit.mock.calls[0][0]).toBe("SET_ALARM_AUDIO");
7782
expect(state.audioObject).toBeDefined();
7883
expect(state.audioObject.onplay).toBeDefined();
@@ -120,7 +125,8 @@ describe("alarm/actions", () => {
120125
});
121126

122127
test("Plays default audio", () => {
123-
actions.playSound({ state });
128+
state.audioObject = new Audio();
129+
actions.playSound({ state, dispatch: dispatchMock });
124130
expect(audioPlaySpy).toHaveBeenCalled();
125131
});
126132

0 commit comments

Comments
 (0)