diff options
Diffstat (limited to 'web')
-rw-r--r-- | web/package.json | 1 | ||||
-rw-r--r-- | web/src/js/__tests__/components/Header/FilterDocsSpec.js | 19 | ||||
-rw-r--r-- | web/yarn.lock | 10 |
3 files changed, 30 insertions, 0 deletions
diff --git a/web/package.json b/web/package.json index 94b0ee60..be63120d 100644 --- a/web/package.json +++ b/web/package.json @@ -25,6 +25,7 @@ "dependencies": { "bootstrap": "^3.3.7", "classnames": "^2.2.5", + "jest-fetch-mock": "^1.1.1", "lodash": "^4.17.4", "prop-types": "^15.5.0", "react": "^15.4.2", diff --git a/web/src/js/__tests__/components/Header/FilterDocsSpec.js b/web/src/js/__tests__/components/Header/FilterDocsSpec.js new file mode 100644 index 00000000..cb722d6d --- /dev/null +++ b/web/src/js/__tests__/components/Header/FilterDocsSpec.js @@ -0,0 +1,19 @@ +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', () => { + + 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) + }) + +}) diff --git a/web/yarn.lock b/web/yarn.lock index 602b4916..069a8590 100644 --- a/web/yarn.lock +++ b/web/yarn.lock @@ -2888,6 +2888,12 @@ jest-environment-node@^19.0.0: jest-mock "^19.0.0"
jest-util "^19.0.0"
+jest-fetch-mock@^1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/jest-fetch-mock/-/jest-fetch-mock-1.1.1.tgz#7548b6d0c0c77071e9f8652fcb4f8d537e988d1f"
+ dependencies:
+ whatwg-fetch "1.0.0"
+
jest-file-exists@^19.0.0:
version "19.0.0"
resolved "https://registry.yarnpkg.com/jest-file-exists/-/jest-file-exists-19.0.0.tgz#cca2e587a11ec92e24cfeab3f8a94d657f3fceb8"
@@ -5180,6 +5186,10 @@ whatwg-encoding@^1.0.1: dependencies:
iconv-lite "0.4.13"
+whatwg-fetch@1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-1.0.0.tgz#01c2ac4df40e236aaa18480e3be74bd5c8eb798e"
+
whatwg-fetch@>=0.10.0:
version "2.0.2"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.2.tgz#fe294d1d89e36c5be8b3195057f2e4bc74fc980e"
|