Commit d5949886 authored by Amaury Martiny's avatar Amaury Martiny

Add basic tests

parent 423b719b
......@@ -31,7 +31,7 @@
"start": "npm-run-all -p start-*",
"start-css": "npm run build-css -- --watch --recursive",
"start-js": "react-app-rewired start",
"test": "echo Skipped."
"test": "react-app-rewired test --env=jsdom"
},
"dependencies": {
"@parity/api": "^2.1.22",
......@@ -56,6 +56,7 @@
},
"devDependencies": {
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"capitalize": "^1.0.0",
"node-sass": "^4.9.0",
"node-sass-chokidar": "^1.2.2",
"npm-run-all": "^4.1.2",
......
......@@ -175,6 +175,7 @@ class SendStore {
@action
setEstimated = estimated => {
this.estimated = estimated.mul(GAS_MULT_FACTOR);
debug('Estimated gas.', +estimated);
};
@action
......
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
//
// SPDX-License-Identifier: BSD-3-Clause
/* eslint-env jest */
import sendStore from './sendStore';
import * as storeTests from '../utils/testHelpers/storeTests';
storeTests.setterTest(sendStore, 'blockNumber');
storeTests.setterTest(sendStore, 'tokenAddress');
storeTests.setterTest(sendStore, 'tx');
storeTests.setterTest(sendStore, 'txStatus');
describe('@computed confirmations', () => {
test('return correct value if txStatus is not set', () => {
sendStore.setTxStatus(null);
expect(sendStore.confirmations).toBe(-1);
});
test('return correct value if txStatus is not `confirmed`', () => {
sendStore.setTxStatus({ estimating: true });
expect(sendStore.confirmations).toBe(-1);
});
test('return correct value if txStatus is `confirmed`', () => {
sendStore.setBlockNumber(5);
sendStore.setTxStatus({ confirmed: { blockNumber: 4 } });
expect(sendStore.confirmations).toBe(1);
});
});
......@@ -3,14 +3,12 @@
//
// SPDX-License-Identifier: BSD-3-Clause
/* eslint-env mocha */
/* eslint-env jest */
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import capitalize from 'capitalize';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
export const setterTest = (store, variableName) =>
test(`should correctly set ${variableName}`, () => {
store[`set${capitalize(variableName)}`]('foo');
expect(store[variableName]).toEqual('foo');
});
......@@ -2866,6 +2866,10 @@ caniuse-lite@^1.0.30000748, caniuse-lite@^1.0.30000792, caniuse-lite@^1.0.300008
version "1.0.30000858"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000858.tgz#f6f203a9128bac507136de1cf6cfd966d2df027c"
capitalize@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/capitalize/-/capitalize-1.0.0.tgz#dc802c580aee101929020d2ca14b4ca8a0ae44be"
capture-stack-trace@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment