aboutsummaryrefslogtreecommitdiffstats
path: root/web/src
diff options
context:
space:
mode:
authorMatthew Shao <me@matshao.com>2017-05-26 17:23:57 +0800
committerMatthew Shao <me@matshao.com>2017-05-26 17:23:57 +0800
commit05d78a8353370fe60e06bc75c1fe658b735ea2ed (patch)
tree3533f0262a5c09833245f376fce11845044b632f /web/src
parent653505e734216d86459619d636c0d1f08f84b7f5 (diff)
downloadmitmproxy-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.js21
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()
+ })
})