Skip to content

Commit

Permalink
Tests2/#6 (#64)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
cch5ng authored Apr 5, 2017
1 parent d0ad3f1 commit 22d9a42
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// .babelrc
{
"presets": ["es2015", "react"]
}
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions src/components/AllQuestions.test.js
Original file line number Diff line number Diff line change
@@ -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(
<AllQuestions />
);

expect(allQuestions).toBeDefined;
});
16 changes: 16 additions & 0 deletions src/components/Child.test.js
Original file line number Diff line number Diff line change
@@ -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(
<MemoryRouter initialEntries={[ '/child/defaultUrl' ]}>
<Child />
</MemoryRouter>
);

expect(child).toBeDefined;
});
16 changes: 16 additions & 0 deletions src/components/Favorites.test.js
Original file line number Diff line number Diff line change
@@ -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(
<MemoryRouter initialEntries={[ '/favorites' ]}>
<Favorites />
</MemoryRouter>
);

expect(favorites).toBeDefined;
});
16 changes: 16 additions & 0 deletions src/components/RandomQuestions.test.js
Original file line number Diff line number Diff line change
@@ -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(
<MemoryRouter initialEntries={[ '/random' ]}>
<RandomQuestions />
</MemoryRouter>
);

expect(randomQuestions).toBeDefined;
});

0 comments on commit 22d9a42

Please sign in to comment.