Skip to content

Commit

Permalink
Add initial all-app tests (#1303)
Browse files Browse the repository at this point in the history
* add dependency on jest-enzyme

* add test for AppContainer + navigation

* fix lint warnings in app-container.test

* add lint file for web/__tests__

* make circleci run tests one at a time
  • Loading branch information
hawkrives authored Mar 15, 2017
1 parent c2e8936 commit df0868f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 2 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ dependencies:

test:
override:
- yarn test
- yarn test -- --runInBand
1 change: 1 addition & 0 deletions modules/web/__tests__/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends: ../../../.eslintrc-test.yml
36 changes: 36 additions & 0 deletions modules/web/__tests__/app-container.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// @flow

import React from 'react'
import { mount } from 'enzyme'

import configureStore from '../redux'
import ReduxWrapper from '../redux-wrapper'
import Router from 'react-router/lib/Router'
import { createMemoryHistory } from 'history'
import routes from '../routes'

import debug from 'debug'
debug.enable('foo')

test('AppContainer renders', () => {
mount(
<ReduxWrapper store={configureStore()}>
<Router history={createMemoryHistory()} routes={routes} />
</ReduxWrapper>
)
})

test('AppContainer can navigate to /create', () => {
const store = configureStore()
const history = createMemoryHistory()

const app = mount(
<ReduxWrapper store={store}>
<Router history={history} routes={routes} />
</ReduxWrapper>
)

history.push('/create')

expect(app.find('h1').text()).toEqual('Hi there!')
})
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"setupFiles": [
"./config/mocha-harness.js"
],
"setupTestFrameworkScriptFile": "./node_modules/jest-enzyme/lib/index.js",
"collectCoverageFrom": [
"modules/**/*.js"
],
Expand Down Expand Up @@ -155,6 +156,7 @@
"glob": "7.1.1",
"graceful-fs": "4.1.11",
"jest": "19.0.2",
"jest-enzyme": "2.1.2",
"js-beautify": "1.6.11",
"json-loader": "0.5.4",
"junk": "2.1.0",
Expand Down
43 changes: 42 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,12 @@ deep-eql@^0.1.3:
dependencies:
type-detect "0.1.1"

deep-equal-ident@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/deep-equal-ident/-/deep-equal-ident-1.1.1.tgz#06f4b89e53710cd6cea4a7781c7a956642de8dc9"
dependencies:
lodash.isequal "^3.0"

deep-extend@~0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253"
Expand Down Expand Up @@ -1964,6 +1970,12 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"

enzyme-matchers@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/enzyme-matchers/-/enzyme-matchers-2.1.2.tgz#da2c20c3d55b128db3de6a5016f2531066b8061f"
dependencies:
deep-equal-ident "^1.1.1"

[email protected]:
version "2.7.1"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-2.7.1.tgz#76370e1d99e91f73091bb8c4314b7c128cc2d621"
Expand Down Expand Up @@ -3396,6 +3408,12 @@ jest-environment-node@^19.0.2:
jest-mock "^19.0.0"
jest-util "^19.0.2"

[email protected]:
version "2.1.2"
resolved "https://registry.yarnpkg.com/jest-enzyme/-/jest-enzyme-2.1.2.tgz#707187aabef9fbb7d018c1a2853ee9d8674ba629"
dependencies:
enzyme-matchers "^2.1.2"

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"
Expand Down Expand Up @@ -3751,6 +3769,18 @@ lodash._basefor@^3.0.0:
version "3.0.3"
resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2"

lodash._baseisequal@^3.0.0:
version "3.0.7"
resolved "https://registry.yarnpkg.com/lodash._baseisequal/-/lodash._baseisequal-3.0.7.tgz#d8025f76339d29342767dcc887ce5cb95a5b51f1"
dependencies:
lodash.isarray "^3.0.0"
lodash.istypedarray "^3.0.0"
lodash.keys "^3.0.0"

lodash._bindcallback@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e"

lodash._getnative@^3.0.0:
version "3.9.1"
resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5"
Expand Down Expand Up @@ -3807,6 +3837,13 @@ lodash.isarray@^3.0.0:
version "3.0.4"
resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55"

lodash.isequal@^3.0:
version "3.0.4"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-3.0.4.tgz#1c35eb3b6ef0cd1ff51743e3ea3cf7fdffdacb64"
dependencies:
lodash._baseisequal "^3.0.0"
lodash._bindcallback "^3.0.0"

lodash.isplainobject@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz#9a8238ae16b200432960cd7346512d0123fbf4c5"
Expand All @@ -3815,7 +3852,11 @@ lodash.isplainobject@^3.2.0:
lodash.isarguments "^3.0.0"
lodash.keysin "^3.0.0"

lodash.keys@^3.1.2:
lodash.istypedarray@^3.0.0:
version "3.0.6"
resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62"

lodash.keys@^3.0.0, lodash.keys@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a"
dependencies:
Expand Down

0 comments on commit df0868f

Please sign in to comment.