Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Commit

Permalink
Setup tests environment. (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw committed Nov 6, 2018
1 parent ac1d82c commit 023e9eb
Show file tree
Hide file tree
Showing 9 changed files with 3,471 additions and 52 deletions.
3 changes: 3 additions & 0 deletions __mocks__/parityMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
api: {}
};
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint": "npm run lint:css && npm run lint:js",
"lint:css": "stylelint ./src/**/*.css",
"lint:js": "eslint --ignore-path .gitignore ./src/",
"test": "echo \"WARN: npm run test skipped\"",
"test": "jest",
"watch": "webpack --colors --progress --watch"
},
"devDependencies": {
Expand All @@ -43,6 +43,8 @@
"babel-preset-stage-0": "^6.24.1",
"css-loader": "^0.28.1",
"ejs-loader": "0.3.0",
"enzyme": "^3.7.0",
"enzyme-adapter-react-16": "^1.6.0",
"eslint": "^4.4.0",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
Expand All @@ -58,6 +60,7 @@
"happypack": "^3.1.0",
"html-loader": "0.4.4",
"html-webpack-plugin": "^2.30.1",
"jest": "^23.6.0",
"json-loader": "0.5.4",
"postcss-import": "10.0.0",
"postcss-loader": "2.0.6",
Expand All @@ -71,5 +74,12 @@
"webpack": "^3.5.5"
},
"dependencies": {},
"peerDependencies": {}
"peerDependencies": {},
"jest": {
"moduleNameMapper": {
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
"parity$": "<rootDir>/__mocks__/parityMock.js"
},
"setupTestFrameworkScriptFile": "<rootDir>/test.setup.js"
}
}
2 changes: 1 addition & 1 deletion src/Application/application.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('dapps/localtx/Application', () => {
it('renders without crashing', () => {
const rendered = shallow(<Application />);

expect(rendered).to.be.defined;
expect(rendered).toBeDefined();
});
});
});
3 changes: 2 additions & 1 deletion src/Transaction/transaction.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
}

.edit {
label, input {
label,
input {
display: block;
}
}
19 changes: 13 additions & 6 deletions src/Transaction/transaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,38 @@ import '@parity/shared/lib/environment/tests';

// Mock API for tests
import * as Api from '../parity';
Api.api = {
util: EthApi.prototype.util
};

import BigNumber from 'bignumber.js';
import { Transaction, LocalTransaction } from './transaction';

Api.api.util = EthApi.prototype.util;

describe('dapps/localtx/Transaction', () => {
describe('rendering', () => {
it('renders without crashing', () => {
const transaction = {
hash: '0x1234567890',
from: '0x123467',
nonce: new BigNumber(15),
gasPrice: new BigNumber(10),
gas: new BigNumber(10)
};

const stats = {
firstSeen: 1,
propagatedTo: {}
};

const rendered = shallow(
<Transaction
idx={ 1 }
isLocal={ false }
transaction={ transaction }
blockNumber={ new BigNumber(0) }
stats={ stats }
/>
);

expect(rendered).to.be.defined;
expect(rendered).toBeDefined();
});
});
});
Expand All @@ -61,7 +68,7 @@ describe('dapps/localtx/LocalTransaction', () => {
/>
);

expect(rendered).to.be.defined;
expect(rendered).toBeDefined();
});
});
});
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import React from 'react';
import { AppContainer } from 'react-hot-loader';

import injectTapEventPlugin from 'react-tap-event-plugin';
injectTapEventPlugin();

import Application from './Application';

import '@parity/shared/assets/fonts/Roboto/font.css';
import '@parity/shared/assets/fonts/RobotoMono/font.css';
import './style.css';

injectTapEventPlugin();

ReactDOM.render(
<AppContainer>
<Application />
Expand Down
6 changes: 6 additions & 0 deletions test.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Enzyme from 'enzyme';
import EnzymeAdapter from 'enzyme-adapter-react-16';

Enzyme.configure({
adapter: new EnzymeAdapter()
});

0 comments on commit 023e9eb

Please sign in to comment.