diff options
author | Matthew Shao <me@matshao.com> | 2017-06-01 20:33:22 +0800 |
---|---|---|
committer | Matthew Shao <me@matshao.com> | 2017-06-01 20:33:22 +0800 |
commit | de3042911a5a61a8b47fbd12ee0650e929a04315 (patch) | |
tree | 73273b6ef927138a5df2f7d9b49fe2ddb9715446 /web/src | |
parent | f4567bc9c879d3b3b87196bbf9243a4c894bd5ed (diff) | |
download | mitmproxy-de3042911a5a61a8b47fbd12ee0650e929a04315.tar.gz mitmproxy-de3042911a5a61a8b47fbd12ee0650e929a04315.tar.bz2 mitmproxy-de3042911a5a61a8b47fbd12ee0650e929a04315.zip |
[web] Add tests for js/components/ContentView/CodeEditor.jsx
Diffstat (limited to 'web/src')
-rw-r--r-- | web/src/js/__tests__/components/ContentView/CodeEditorSpec.js | 22 | ||||
-rw-r--r-- | web/src/js/__tests__/components/ContentView/__snapshots__/CodeEditorSpec.js.snap | 8 |
2 files changed, 30 insertions, 0 deletions
diff --git a/web/src/js/__tests__/components/ContentView/CodeEditorSpec.js b/web/src/js/__tests__/components/ContentView/CodeEditorSpec.js new file mode 100644 index 00000000..2698f13f --- /dev/null +++ b/web/src/js/__tests__/components/ContentView/CodeEditorSpec.js @@ -0,0 +1,22 @@ +jest.mock('react-codemirror') +import React from 'react' +import renderer from 'react-test-renderer' +import CodeEditor from '../../../components/ContentView/CodeEditor' + +describe('CodeEditor Component', () => { + let content = "foo content", + changeFn = jest.fn(), + codeEditor = renderer.create( + <CodeEditor content={content} onChange={changeFn}/> + ), + tree = codeEditor.toJSON() + it('should render correctly', () => { + expect(tree).toMatchSnapshot() + }) + + it('should handle key down', () => { + let mockEvent = { stopPropagation: jest.fn() } + tree.props.onKeyDown(mockEvent) + expect(mockEvent.stopPropagation).toBeCalled() + }) +}) diff --git a/web/src/js/__tests__/components/ContentView/__snapshots__/CodeEditorSpec.js.snap b/web/src/js/__tests__/components/ContentView/__snapshots__/CodeEditorSpec.js.snap new file mode 100644 index 00000000..7e688a60 --- /dev/null +++ b/web/src/js/__tests__/components/ContentView/__snapshots__/CodeEditorSpec.js.snap @@ -0,0 +1,8 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CodeEditor Component should render correctly 1`] = ` +<div + className="codeeditor" + onKeyDown={[Function]} +/> +`; |