Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Commit a3da34a

Browse files
committed
Feat: finish implementation of jest
- Remove old karma packages - Alter generators with new setup, using jest and enzyme
1 parent 18de2ba commit a3da34a

File tree

7 files changed

+33
-51
lines changed

7 files changed

+33
-51
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import {{ properCase name }} from '../index';
2-
3-
import expect from 'expect';
42
import { shallow } from 'enzyme';
3+
import { shallowToJson } from 'enzyme-to-json';
54
import React from 'react';
65

76
describe('<{{ properCase name }} />', () => {
8-
it('Expect to have unit tests specified', () => {
9-
expect(true).toEqual(false);
7+
it('should render with default props', () => {
8+
const wrapper = shallow(
9+
<{{ properCase name }} />
10+
);
11+
expect(shallowToJson(wrapper)).toMatchSnapshot();
1012
});
1113
});
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import {
2-
{{ uppercase name }}_DEFAULT_ACTION,
3-
} from './constants';
1+
import * as types from './constants';
42

53
// {{ camelCase name }}defaultAction :: None -> {Action}
64
export const {{ camelCase name }}DefaultAction = () => ({
7-
type: {{ uppercase name }}_DEFAULT_ACTION,
5+
type: types.{{ uppercase name }}_DEFAULT_ACTION,
86
});
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
import expect from 'expect';
2-
import {
3-
{{ camelCase name }}DefaultAction,
4-
} from '../actions';
5-
import {
6-
{{ uppercase name }}_DEFAULT_ACTION,
7-
} from '../constants';
2+
import * as actions from '../actions';
3+
import * as types from '../constants';
84

95
describe('{{ properCase name }} actions', () => {
106
describe('Default Action', () => {
117
it('has a type of DEFAULT_ACTION', () => {
128
const expected = {
13-
type: {{ uppercase name }}_DEFAULT_ACTION,
9+
type: types.{{ uppercase name }}_DEFAULT_ACTION,
1410
};
15-
expect({{ camelCase name }}DefaultAction()).toEqual(expected);
11+
expect(actions.{{ camelCase name }}DefaultAction()).toEqual(expected);
1612
});
1713
});
1814
});
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import {
2-
{{ uppercase name }}_DEFAULT_ACTION,
3-
} from './constants';
1+
import * as types from './constants';
42

5-
const initialState = {
3+
export const initialState = {
64
// Initial State goes here!
75
};
86

97
const {{ camelCase name }}Reducer =
108
(state = initialState, action) => {
119
switch (action.type) {
12-
case DEFAULT_ACTION:
10+
case types.DEFAULT_ACTION:
1311
return state;
1412
default:
1513
return state;
1614
}
17-
};
15+
};
1816

1917
export default {{ camelCase name }}Reducer;

config/generators/container/reducer.test.js.hbs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import expect from 'expect';
2-
import {{ camelCase name }}Reducer from '../reducer';
3-
4-
const initialState = {
5-
// Initial State goes here!
6-
};
2+
import {{ camelCase name }}Reducer, { initialState } from '../reducer';
73

84
describe('{{ camelCase name }}Reducer', () => {
95
it('returns the initial state', () => {
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import {{ properCase name }} from '../index';
2-
3-
import expect from 'expect';
42
import { shallow } from 'enzyme';
3+
import { shallowToJson } from 'enzyme-to-json';
54
import React from 'react';
5+
import configureMockStore from 'redux-mock-store';
6+
import thunk from 'redux-thunk';
7+
import { initialState } from '../reducer';
8+
9+
const middlewares = [thunk];
10+
const mockStore = configureMockStore(middlewares);
611

712
describe('<{{ properCase name }} />', () => {
8-
it('Expect to have unit tests specified', () => {
9-
expect(true).toEqual(false);
13+
it('should render with default props', () => {
14+
const store = mockStore(initialState);
15+
const wrapper = shallow(
16+
<{{ properCase name }} store={store} />
17+
);
18+
expect(shallowToJson(wrapper)).toMatchSnapshot();
1019
});
1120
});

package.json

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"test": {
1515
"plugins": [
1616
[
17-
"babel-plugin-webpack-loaders", {
17+
"babel-plugin-webpack-loaders",
18+
{
1819
"config": "./config/testing/webpack.test.config.js",
1920
"verbose": false
2021
}
@@ -126,31 +127,13 @@
126127
"babel-eslint": "^5.0.0-beta4",
127128
"babel-jest": "^15.0.0",
128129
"babel-preset-es2015": "^6.9.0",
129-
"chai": "^3.4.1",
130-
"chai-enzyme": "^0.5.0",
131-
"chai-immutable": "^1.5.3",
132-
"chai-jsx": "^1.0.1",
133130
"cross-env": "^2.0.0",
134131
"enzyme": "^2.4.1",
132+
"enzyme-to-json": "^1.0.3",
135133
"eslint": "^1.10.3",
136134
"eslint-config-airbnb": "^4.0.0",
137135
"eslint-loader": "^1.1.1",
138136
"eslint-plugin-react": "^3.11.3",
139-
"isparta": "^4.0.0",
140-
"isparta-loader": "2.0.0",
141-
"jest-webpack-alias": "^3.2.2",
142-
"jsdom": "^7.2.0",
143-
"karma": "1.1.1",
144-
"karma-chrome-launcher": "1.0.1",
145-
"karma-coverage": "1.1.1",
146-
"karma-firefox-launcher": "1.0.0",
147-
"karma-ie-launcher": "1.0.0",
148-
"karma-mocha": "1.1.1",
149-
"karma-mocha-reporter": "2.0.4",
150-
"karma-safari-launcher": "1.0.0",
151-
"karma-sourcemap-loader": "0.3.7",
152-
"karma-webpack": "1.7.0",
153-
"mocha": "^2.3.4",
154137
"npm-install-webpack-plugin": "^4.0.3",
155138
"null-loader": "0.1.1",
156139
"plop": "1.5.0",

0 commit comments

Comments
 (0)