mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
[web] js/components/Header/FilterDocs.jsx coverage ++
This commit is contained in:
parent
653505e734
commit
05d78a8353
@ -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)
|
||||
})
|
||||
|
||||
it('should render correctly when fetch success', () => {
|
||||
expect(tree).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user