Merge pull request #4 from andrerfneves/feature/testing-suite
Feature/testing suite
This commit is contained in:
commit
a90ce194fe
|
@ -4,9 +4,10 @@
|
|||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"mocha": true
|
||||
"mocha": true,
|
||||
"jest/globals": true
|
||||
},
|
||||
"plugins": ["flowtype"],
|
||||
"plugins": ["flowtype", "jest"],
|
||||
"settings": {
|
||||
"flowtype": {
|
||||
"onlyFilesWithFlowAnnotation": true
|
||||
|
|
|
@ -5,3 +5,5 @@ dist
|
|||
flow-coverage
|
||||
build
|
||||
.docz
|
||||
coverage
|
||||
flow-typed
|
|
@ -24,7 +24,7 @@ yarn install
|
|||
To run the application on port 8080
|
||||
|
||||
```bash
|
||||
yarn dev
|
||||
yarn start
|
||||
```
|
||||
|
||||
## License
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import configureStore from 'redux-mock-store';
|
||||
|
||||
import { ADD_TODO } from '../../app/constants/actions';
|
||||
|
||||
import { addTodo } from '../../app/actions/add-todo';
|
||||
|
||||
const store = configureStore()();
|
||||
|
||||
describe('Todo Actions', () => {
|
||||
beforeEach(() => store.clearActions());
|
||||
|
||||
test('should create an action to add a new todo', () => {
|
||||
const text = 'Hello World!';
|
||||
|
||||
store.dispatch(addTodo(text));
|
||||
expect(store.getActions()[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
type: ADD_TODO,
|
||||
payload: {
|
||||
text,
|
||||
id: expect.any(String),
|
||||
editing: false,
|
||||
createdAt: expect.any(Number),
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
import React from 'react';
|
||||
import { render } from 'react-testing-library';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import 'jest-dom/extend-expect';
|
||||
|
||||
import { SidebarComponent } from '../../app/components/sidebar/index';
|
||||
|
||||
describe('<Sidebar />', () => {
|
||||
describe('render()', () => {
|
||||
test('should render correctly', () => {
|
||||
const { asFragment } = render(
|
||||
<MemoryRouter>
|
||||
<SidebarComponent />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,30 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<Sidebar /> render() should render correctly 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="sc-bdVaJa fnXMXv"
|
||||
>
|
||||
<a
|
||||
href="/"
|
||||
>
|
||||
Dashboard
|
||||
</a>
|
||||
<a
|
||||
href="/send"
|
||||
>
|
||||
Send
|
||||
</a>
|
||||
<a
|
||||
href="/receive"
|
||||
>
|
||||
Receive
|
||||
</a>
|
||||
<a
|
||||
href="/settings"
|
||||
>
|
||||
Settings
|
||||
</a>
|
||||
</div>
|
||||
</DocumentFragment>
|
||||
`;
|
|
@ -0,0 +1,16 @@
|
|||
import { getApp } from '../setup/utils';
|
||||
|
||||
describe('ZCash', () => {
|
||||
const app = getApp();
|
||||
|
||||
beforeEach(() => app.start());
|
||||
afterEach(() => {
|
||||
app.stop();
|
||||
});
|
||||
|
||||
test('should open the window', () => {
|
||||
app.client.getWindowCount().then((count) => {
|
||||
expect(count).equal(1);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,26 @@
|
|||
import todoReducer from '../../app/reducers/todo';
|
||||
import { ADD_TODO } from '../../app/constants/actions';
|
||||
|
||||
describe('Todo Reducer', () => {
|
||||
test('should return the valid initial state', () => {
|
||||
const action = { type: 'UNKNOWN_ACTION' };
|
||||
const initialState = [];
|
||||
|
||||
expect(todoReducer(undefined, action)).toEqual(initialState);
|
||||
});
|
||||
|
||||
test('should add a new todo', () => {
|
||||
const action = {
|
||||
type: ADD_TODO,
|
||||
payload: {
|
||||
id: 'abc123',
|
||||
text: 'Hello World!',
|
||||
editing: false,
|
||||
createdAt: new Date().getTime(),
|
||||
},
|
||||
};
|
||||
const expectedState = [action.payload];
|
||||
|
||||
expect(todoReducer(undefined, action)).toEqual(expectedState);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,2 @@
|
|||
jest.DEFAULT_TIMEOUT_INTERVAL = 20000;
|
||||
jest.setTimeout(20000);
|
|
@ -0,0 +1,11 @@
|
|||
import electron from 'electron';
|
||||
import { Application } from 'spectron';
|
||||
|
||||
export const TIMEOUT = 10000;
|
||||
|
||||
export const getApp = () => new Application({
|
||||
path: electron,
|
||||
args: ['.'],
|
||||
startTimeout: TIMEOUT,
|
||||
waitTimeout: TIMEOUT,
|
||||
});
|
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
|
@ -19,7 +19,9 @@
|
|||
"preelectron:prepare": "yarn build",
|
||||
"icon:build": "./node_modules/.bin/electron-icon-maker --input=build-assets/icon.png --output=./build",
|
||||
"docz:dev": "docz dev",
|
||||
"docz:build": "docz build"
|
||||
"docz:build": "docz build",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch"
|
||||
},
|
||||
"author": {
|
||||
"name": "André Neves",
|
||||
|
@ -53,17 +55,23 @@
|
|||
"eslint-config-airbnb": "^17.1.0",
|
||||
"eslint-plugin-flowtype": "^3.2.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-jest": "^22.1.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.0.3",
|
||||
"eslint-plugin-react": "^7.7.0",
|
||||
"file-loader": "^2.0.0",
|
||||
"flow-bin": "^0.86.0",
|
||||
"glow": "^1.2.2",
|
||||
"html-webpack-plugin": "^3.1.0",
|
||||
"jest": "^23.6.0",
|
||||
"jest-dom": "^2.1.1",
|
||||
"node-sass": "^4.8.3",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"react-testing-library": "^5.3.1",
|
||||
"redux-logger": "^3.0.6",
|
||||
"redux-mock-store": "^1.5.3",
|
||||
"sass-loader": "^7.1.0",
|
||||
"spectron": "^5.0.0",
|
||||
"style-loader": "^0.23.1",
|
||||
"uglifyjs-webpack-plugin": "^2.0.1",
|
||||
"wait-on": "^3.2.0",
|
||||
|
@ -118,5 +126,14 @@
|
|||
"dmg"
|
||||
]
|
||||
}
|
||||
},
|
||||
"jest": {
|
||||
"setupTestFrameworkScriptFile": "<rootDir>/__tests__/setup/jest.js",
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/__tests__/setup/"
|
||||
]
|
||||
},
|
||||
"resolutions": {
|
||||
"babel-core": "7.0.0-bridge.0"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue