Merge pull request #4 from andrerfneves/feature/testing-suite

Feature/testing suite
This commit is contained in:
George Lima 2018-11-28 22:06:25 -03:00 committed by GitHub
commit a90ce194fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1700 additions and 13297 deletions

View File

@ -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

4
.gitignore vendored
View File

@ -4,4 +4,6 @@ dist
.DS_Store
flow-coverage
build
.docz
.docz
coverage
flow-typed

View File

@ -24,9 +24,9 @@ yarn install
To run the application on port 8080
```bash
yarn dev
yarn start
```
## License
© Zcash Foundation 2018
© Zcash Foundation 2018

View File

@ -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),
},
}),
);
});
});

View File

@ -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();
});
});
});

View File

@ -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>
`;

View File

@ -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);
});
});
});

View File

@ -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);
});
});

2
__tests__/setup/jest.js Normal file
View File

@ -0,0 +1,2 @@
jest.DEFAULT_TIMEOUT_INTERVAL = 20000;
jest.setTimeout(20000);

11
__tests__/setup/utils.js Normal file
View File

@ -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,
});

13253
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -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"
}
}

1579
yarn.lock

File diff suppressed because it is too large Load Diff