|
1 |
| -import '@testing-library/jest-dom' |
2 |
| -import fetch from 'isomorphic-unfetch' |
3 |
| -import {render, fireEvent, screen} from '@testing-library/vue' |
4 |
| -import VueApollo from 'vue-apollo' |
5 |
| -import {InMemoryCache} from 'apollo-cache-inmemory' |
6 |
| -import ApolloClient from 'apollo-boost' |
| 1 | +test.todo('Your test suite must contain at least one test.') |
| 2 | +// import '@testing-library/jest-dom' |
| 3 | +// import fetch from 'isomorphic-unfetch' |
| 4 | +// import {render, fireEvent, screen} from '@testing-library/vue' |
| 5 | +// import VueApollo from 'vue-apollo' |
| 6 | +// import {InMemoryCache} from 'apollo-cache-inmemory' |
| 7 | +// import ApolloClient from 'apollo-boost' |
7 | 8 |
|
8 |
| -// Since vue-apollo doesn't provides a MockProvider for Vue, |
9 |
| -// you need to use some kind of mocks for the queries. |
| 9 | +// // Since vue-apollo doesn't provides a MockProvider for Vue, |
| 10 | +// // you need to use some kind of mocks for the queries. |
10 | 11 |
|
11 |
| -// We recommend using Mock Service Worker library to declaratively mock API communication |
12 |
| -// in your tests instead of stubbing window.fetch, or relying on third-party adapters. |
| 12 | +// // We recommend using Mock Service Worker library to declaratively mock API communication |
| 13 | +// // in your tests instead of stubbing window.fetch, or relying on third-party adapters. |
13 | 14 |
|
14 |
| -import {setupServer} from 'msw/node' |
15 |
| -import {graphql} from 'msw' |
| 15 | +// import {setupServer} from 'msw/node' |
| 16 | +// import {graphql} from 'msw' |
16 | 17 |
|
17 |
| -import Component from './components/VueApollo.vue' |
| 18 | +// import Component from './components/VueApollo.vue' |
18 | 19 |
|
19 |
| -const apolloClient = new ApolloClient({ |
20 |
| - uri: 'http://localhost:3020/graphql', |
21 |
| - cache: new InMemoryCache({ |
22 |
| - addTypename: false, |
23 |
| - }), |
24 |
| - fetch, |
25 |
| -}) |
| 20 | +// const apolloClient = new ApolloClient({ |
| 21 | +// uri: 'http://localhost:3020/graphql', |
| 22 | +// cache: new InMemoryCache({ |
| 23 | +// addTypename: false, |
| 24 | +// }), |
| 25 | +// fetch, |
| 26 | +// }) |
26 | 27 |
|
27 |
| -const server = setupServer( |
28 |
| - ...[ |
29 |
| - graphql.mutation('updateUser', (req, res, ctx) => { |
30 |
| - const {variables} = req |
| 28 | +// const server = setupServer( |
| 29 | +// ...[ |
| 30 | +// graphql.mutation('updateUser', (req, res, ctx) => { |
| 31 | +// const {variables} = req |
31 | 32 |
|
32 |
| - return res( |
33 |
| - ctx.data({ |
34 |
| - updateUser: {id: variables.input.id, email: variables.input.email}, |
35 |
| - }), |
36 |
| - ) |
37 |
| - }), |
38 |
| - graphql.query('User', (req, res, ctx) => { |
39 |
| - return res(ctx.data({user: {id: '1', email: '[email protected]'}})) |
40 |
| - }), |
41 |
| - ], |
42 |
| -) |
| 33 | +// return res( |
| 34 | +// ctx.data({ |
| 35 | +// updateUser: {id: variables.input.id, email: variables.input.email}, |
| 36 | +// }), |
| 37 | +// ) |
| 38 | +// }), |
| 39 | +// graphql.query('User', (req, res, ctx) => { |
| 40 | +// return res(ctx.data({user: {id: '1', email: 'alice@example.com'}})) |
| 41 | +// }), |
| 42 | +// ], |
| 43 | +// ) |
43 | 44 |
|
44 |
| -beforeAll(() => server.listen()) |
45 |
| -afterEach(() => server.resetHandlers()) |
46 |
| -afterAll(() => server.close()) |
| 45 | +// beforeAll(() => server.listen()) |
| 46 | +// afterEach(() => server.resetHandlers()) |
| 47 | +// afterAll(() => server.close()) |
47 | 48 |
|
48 |
| -test('mocking queries and mutations', async () => { |
49 |
| - render(Component, {props: {id: '1'}}, localVue => { |
50 |
| - localVue.use(VueApollo) |
| 49 | +// test('mocking queries and mutations', async () => { |
| 50 | +// render(Component, {props: {id: '1'}}, localVue => { |
| 51 | +// localVue.use(VueApollo) |
51 | 52 |
|
52 |
| - return { |
53 |
| - apolloProvider: new VueApollo({defaultClient: apolloClient}), |
54 |
| - } |
55 |
| - }) |
| 53 | +// return { |
| 54 | +// apolloProvider: new VueApollo({defaultClient: apolloClient}), |
| 55 | +// } |
| 56 | +// }) |
56 | 57 |
|
57 |
| - //Initial rendering will be in the loading state, |
58 |
| - expect(screen.getByText('Loading')).toBeInTheDocument() |
| 58 | +// //Initial rendering will be in the loading state, |
| 59 | +// expect(screen.getByText('Loading')).toBeInTheDocument() |
59 | 60 |
|
60 |
| - expect( |
61 |
| - await screen.findByText('Email: [email protected]'), |
62 |
| - ).toBeInTheDocument() |
| 61 | +// expect( |
| 62 | +// await screen.findByText('Email: [email protected]'), |
| 63 | +// ).toBeInTheDocument() |
63 | 64 |
|
64 |
| - await fireEvent.update( |
65 |
| - screen.getByLabelText('Email'), |
66 |
| - |
67 |
| - ) |
| 65 | +// await fireEvent.update( |
| 66 | +// screen.getByLabelText('Email'), |
| 67 | + |
| 68 | +// ) |
68 | 69 |
|
69 |
| - await fireEvent.click(screen.getByRole('button', {name: 'Change email'})) |
| 70 | +// await fireEvent.click(screen.getByRole('button', {name: 'Change email'})) |
70 | 71 |
|
71 |
| - expect( |
72 |
| - await screen.findByText('Email: [email protected]'), |
73 |
| - ).toBeInTheDocument() |
74 |
| -}) |
| 72 | +// expect( |
| 73 | +// await screen.findByText('Email: [email protected]'), |
| 74 | +// ).toBeInTheDocument() |
| 75 | +// }) |
0 commit comments