Skip to content

Commit

Permalink
Merge pull request #1805 from MetRonnie/warnings
Browse files Browse the repository at this point in the history
Tests: fix mocking of apollo client
  • Loading branch information
markgrahamdawson authored May 23, 2024
2 parents 1ecfe08 + 0b68fa8 commit 57cef86
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/unit/services/workflow.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { createStore } from 'vuex'
import storeOptions from '@/store/options'
import CylcTreeCallback from '@/services/treeCallback'
import { vi } from 'vitest'
import sinon from 'sinon'
import { print } from 'graphql/language'
import gql from 'graphql-tag'
Expand All @@ -26,7 +27,6 @@ import 'cross-fetch/polyfill'
import Subscription from '@/model/Subscription.model'
import SubscriptionQuery from '@/model/SubscriptionQuery.model'
import WorkflowService from '@/services/workflow.service'
import * as graphqlModule from '@/graphql/index'
import ViewState from '@/model/ViewState.model'
import { TreeCallback, WorkflowCallback } from './testCallback'

Expand All @@ -37,10 +37,6 @@ describe('WorkflowService', () => {
* @type {String}
*/
const url = '/graphql'
/**
* @type {ApolloClient}
*/
let apolloClient
/**
* @type {SubscriptionClient|null}
*/
Expand All @@ -67,12 +63,15 @@ describe('WorkflowService', () => {
let subscription
beforeEach(() => {
sandbox.stub(console, 'debug')
apolloClient = sandbox.spy({
query: () => {},
subscribe: (options) => {}
})
vi.mock('@/graphql/index', () => ({
createApolloClient: () => ({
query: vi.fn(),
subscribe: () => ({
subscribe: vi.fn()
}),
})
}))
subscriptionClient = null
sandbox.stub(graphqlModule, 'createApolloClient').returns(apolloClient)
// TODO: really load some mutations
sandbox.stub(WorkflowService.prototype, 'loadTypes').returns(
Promise.resolve({
Expand Down

0 comments on commit 57cef86

Please sign in to comment.