diff options
author | Matthew Shao <me@matshao.com> | 2017-05-26 17:23:57 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-05-26 17:23:57 +0800 |
commit | 05d78a8353370fe60e06bc75c1fe658b735ea2ed (patch) | |
tree | 3533f0262a5c09833245f376fce11845044b632f /web/src | |
parent | 653505e734216d86459619d636c0d1f08f84b7f5 (diff) | |
download | mitmproxy-05d78a8353370fe60e06bc75c1fe658b735ea2ed.tar.gz mitmproxy-05d78a8353370fe60e06bc75c1fe658b735ea2ed.tar.bz2 mitmproxy-05d78a8353370fe60e06bc75c1fe658b735ea2ed.zip |
[web] js/components/Header/FilterDocs.jsx coverage ++
Diffstat (limited to 'web/src')
-rw-r--r-- | web/src/js/__tests__/components/Header/FilterDocsSpec.js | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/web/src/js/__tests__/components/Header/FilterDocsSpec.js b/web/src/js/__tests__/components/Header/FilterDocsSpec.js index cb722d6d..a8cc5e97 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(<FilterDocs/>), - tree = filterDocs.toJSON() - // [TODO] doc in render() could not be set correctly. - console.log(tree) - }) + let filterDocs = renderer.create(<FilterDocs/>), + tree = filterDocs.toJSON() + it('should render correctly when fetch success', () => { + expect(tree).toMatchSnapshot() + }) }) |