diff --git a/web/src/js/__tests__/components/Header/FilterDocsSpec.js b/web/src/js/__tests__/components/Header/FilterDocsSpec.js index cb722d6d5..a8cc5e972 100644 --- a/web/src/js/__tests__/components/Header/FilterDocsSpec.js +++ b/web/src/js/__tests__/components/Header/FilterDocsSpec.js @@ -1,19 +1,18 @@ import React from 'react' import renderer from 'react-test-renderer' import FilterDocs from '../../../components/Header/FilterDocs' -import mockFetch from 'jest-fetch-mock' - -global.fetch = mockFetch describe('FilterDocs Component', () => { + let mockResponse = { json: + jest.fn(() => { return { commands: [['cmd1', 'foo'], ['cmd2', 'bar']]}}) + }, + promise = Promise.resolve(mockResponse) + global.fetch = jest.fn(r => { return promise }) - it('should render correctly', () => { - // fetch successes - fetch.mockResponseOnce(JSON.stringify({commands: [['cmd1', 'foo'], ['cmd2', 'bar']]}), {status: 200}) - let filterDocs = renderer.create(), - tree = filterDocs.toJSON() - // [TODO] doc in render() could not be set correctly. - console.log(tree) + let filterDocs = renderer.create(), + tree = filterDocs.toJSON() + + it('should render correctly when fetch success', () => { + expect(tree).toMatchSnapshot() }) - })