Skip to content

Commit 61fc425

Browse files
committed
Fix vuex store warnings in unit tests
1 parent 63bdcc2 commit 61fc425

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

src/store/app.module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
const state = {
18+
const state = () => ({
1919
drawer: null,
2020
title: null,
21-
jobTheme: null
22-
}
21+
jobTheme: null,
22+
})
2323

2424
const mutations = {
2525
setDrawer (state, drawer) {

src/store/options.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { workflows } from './workflows.module'
2121
import { user } from './user.module'
2222

2323
// State
24-
const state = {
24+
const state = () => ({
2525
/**
2626
* Application alert.
2727
*/
@@ -35,7 +35,7 @@ const state = {
3535
* TODO: we can probably remove it and use a different approach for alerts (see bootstrap toast).
3636
*/
3737
refCount: 0
38-
}
38+
})
3939

4040
// Actions
4141
const actions = {

src/store/user.module.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
export const state = {
19-
user: null
20-
}
18+
export const state = () => ({
19+
user: null,
20+
})
2121

2222
export const mutations = {
2323
SET_USER (state, user) {

src/store/workflows.module.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function merge (data, update) {
3535
}
3636
}
3737

38-
const state = {
38+
const state = () => ({
3939
cylcTree: {
4040
$index: {},
4141
children: []
@@ -50,7 +50,7 @@ const state = {
5050
* @type {String}
5151
*/
5252
workflowName: null
53-
}
53+
})
5454

5555
const getters = {
5656
/* Return matching nodes from the store.

tests/unit/utils/graphql.spec.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
import { createStore } from 'vuex'
1918
// need the polyfill as otherwise ApolloClient fails to be imported as it checks for a global fetch object on import...
2019
import 'cross-fetch/polyfill'
2120
import * as graphql from '@/graphql'
21+
import { store } from '@/store/index'
2222
import storeOptions from '@/store/options'
2323

2424
describe('utils', () => {
25-
const store = createStore(storeOptions)
2625
describe('graphql', () => {
2726
describe('ApolloClient', () => {
2827
it('should create an apollo client', () => {
@@ -34,8 +33,8 @@ describe('utils', () => {
3433

3534
describe('SubscriptionClient', () => {
3635
beforeEach(() => {
37-
store.commit('SET_OFFLINE', false)
38-
store.state.offline = false
36+
store.replaceState(storeOptions.state())
37+
expect(store.state.offline).to.be.false
3938
})
4039
it('should create a subscription client', () => {
4140
const subscriptionClient = graphql.createSubscriptionClient(

0 commit comments

Comments
 (0)