Skip to content

Commit 0b68fa8

Browse files
committed
Tests: fix mocking of apollo client
1 parent a3d4460 commit 0b68fa8

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests/unit/services/workflow.service.spec.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import { createStore } from 'vuex'
1919
import storeOptions from '@/store/options'
2020
import CylcTreeCallback from '@/services/treeCallback'
21+
import { vi } from 'vitest'
2122
import sinon from 'sinon'
2223
import { print } from 'graphql/language'
2324
import gql from 'graphql-tag'
@@ -26,7 +27,6 @@ import 'cross-fetch/polyfill'
2627
import Subscription from '@/model/Subscription.model'
2728
import SubscriptionQuery from '@/model/SubscriptionQuery.model'
2829
import WorkflowService from '@/services/workflow.service'
29-
import * as graphqlModule from '@/graphql/index'
3030
import ViewState from '@/model/ViewState.model'
3131
import { TreeCallback, WorkflowCallback } from './testCallback'
3232

@@ -37,10 +37,6 @@ describe('WorkflowService', () => {
3737
* @type {String}
3838
*/
3939
const url = '/graphql'
40-
/**
41-
* @type {ApolloClient}
42-
*/
43-
let apolloClient
4440
/**
4541
* @type {SubscriptionClient|null}
4642
*/
@@ -67,12 +63,15 @@ describe('WorkflowService', () => {
6763
let subscription
6864
beforeEach(() => {
6965
sandbox.stub(console, 'debug')
70-
apolloClient = sandbox.spy({
71-
query: () => {},
72-
subscribe: (options) => {}
73-
})
66+
vi.mock('@/graphql/index', () => ({
67+
createApolloClient: () => ({
68+
query: vi.fn(),
69+
subscribe: () => ({
70+
subscribe: vi.fn()
71+
}),
72+
})
73+
}))
7474
subscriptionClient = null
75-
sandbox.stub(graphqlModule, 'createApolloClient').returns(apolloClient)
7675
// TODO: really load some mutations
7776
sandbox.stub(WorkflowService.prototype, 'loadTypes').returns(
7877
Promise.resolve({

0 commit comments

Comments
 (0)