From 22d9a426f01331e02705fc144feb6093b8e03a6b Mon Sep 17 00:00:00 2001 From: Carol Chung Date: Wed, 5 Apr 2017 14:31:33 -0700 Subject: [PATCH] Tests2/#6 (#64) * fix: #6; add jest and assoc modules * fix: #6; install more test packages, enzyme, jest-cli, etc * fix: #6; basic render test * fix: #6; add config for jest * fix: #6; working child test * fix: #6; test render Favorites * fix: #6; cleanup Child test * fix: #6; basic render test RandomQuestions --- .babelrc | 4 ++++ package.json | 13 ++++++++++++- src/components/AllQuestions.test.js | 13 +++++++++++++ src/components/Child.test.js | 16 ++++++++++++++++ src/components/Favorites.test.js | 16 ++++++++++++++++ src/components/RandomQuestions.test.js | 16 ++++++++++++++++ 6 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 .babelrc create mode 100644 src/components/AllQuestions.test.js create mode 100644 src/components/Child.test.js create mode 100644 src/components/Favorites.test.js create mode 100644 src/components/RandomQuestions.test.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..b3850ff --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +// .babelrc +{ + "presets": ["es2015", "react"] +} \ No newline at end of file diff --git a/package.json b/package.json index 99f187f..0475962 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,21 @@ "name": "react-fe-interview", "version": "0.1.0", "private": true, + "jest": { + "verbose": true + }, "devDependencies": { + "babel-jest": "^19.0.0", + "babel-preset-es2015": "^6.24.0", + "babel-preset-react": "^6.23.0", + "enzyme": "^2.8.0", "gh-pages": "^0.12.0", "html2json": "^1.0.2", - "react-scripts": "0.9.0" + "jest": "^19.0.2", + "jest-cli": "^19.0.2", + "react-addons-test-utils": "^15.4.2", + "react-scripts": "0.9.0", + "react-test-renderer": "^15.4.2" }, "dependencies": { "bootstrap": "^3.3.7", diff --git a/src/components/AllQuestions.test.js b/src/components/AllQuestions.test.js new file mode 100644 index 0000000..7c7c95a --- /dev/null +++ b/src/components/AllQuestions.test.js @@ -0,0 +1,13 @@ +//AllQuestions.test.js + +import React from 'react'; +import {shallow} from 'enzyme'; +import AllQuestions from './AllQuestions'; + +test('AllQuestions renders', () => { + const allQuestions = shallow( + + ); + + expect(allQuestions).toBeDefined; +}); \ No newline at end of file diff --git a/src/components/Child.test.js b/src/components/Child.test.js new file mode 100644 index 0000000..61483f9 --- /dev/null +++ b/src/components/Child.test.js @@ -0,0 +1,16 @@ +//Child.test.js + +import React from 'react'; +import {shallow} from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import Child from './Child'; + +test('Child renders', () => { + const child = shallow( + + + + ); + + expect(child).toBeDefined; +}); \ No newline at end of file diff --git a/src/components/Favorites.test.js b/src/components/Favorites.test.js new file mode 100644 index 0000000..e0f1003 --- /dev/null +++ b/src/components/Favorites.test.js @@ -0,0 +1,16 @@ +//Favorites.test.js + +import React from 'react'; +import {shallow} from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import Favorites from './Favorites'; + +test('Favorites renders', () => { + const favorites = shallow( + + + + ); + + expect(favorites).toBeDefined; +}); \ No newline at end of file diff --git a/src/components/RandomQuestions.test.js b/src/components/RandomQuestions.test.js new file mode 100644 index 0000000..153b845 --- /dev/null +++ b/src/components/RandomQuestions.test.js @@ -0,0 +1,16 @@ +//RandomQuestions.test.js + +import React from 'react'; +import {shallow} from 'enzyme'; +import { MemoryRouter } from 'react-router'; +import RandomQuestions from './RandomQuestions'; + +test('RandomQuestions renders', () => { + const randomQuestions = shallow( + + + + ); + + expect(randomQuestions).toBeDefined; +}); \ No newline at end of file