Skip to content

Commit

Permalink
Merge pull request #1475 from LiskHQ/1433-enable-component-test-in-jest
Browse files Browse the repository at this point in the history
Enable component test in Jest L36 to L65 - Closes #1433 #1434 #1435
  • Loading branch information
osvaldovega authored Nov 9, 2018
2 parents b576b93 + aa32b5b commit c506ed7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 34 deletions.
9 changes: 8 additions & 1 deletion config/setupJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import sinonStubPromise from 'sinon-stub-promise';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import i18next from 'i18next';
// TODO remove next line after upgrading node version to at least 7
import 'es7-object-polyfill';

require('jest-localstorage-mock');

Expand All @@ -19,7 +21,12 @@ chai.use(chaiAsPromised);
sinonStubPromise(sinon);
// eslint-disable-next-line no-undef
jest.useFakeTimers();
i18next.t = key => key;
i18next.t = function (key, o) {
return key.replace(/{{([^{}]*)}}/g, (a, b) => {
const r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
};


// https://github.com/nkbt/react-copy-to-clipboard/issues/20#issuecomment-414065452
Expand Down
61 changes: 31 additions & 30 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,36 +33,36 @@ module.exports = {
// '<rootDir>/src/utils/generateUniqueId.test.js',
// '<rootDir>/src/utils/login.test.js',
'<rootDir>/src/utils/hacks.test.js',
// '<rootDir>/src/components/searchBar/index.test.js',
// '<rootDir>/src/components/accountTransactions/index.test.js',
// '<rootDir>/src/components/multiStep/index.test.js',
// '<rootDir>/src/components/multiStep/multiStepNav.test.js',
// '<rootDir>/src/components/fontIcon/index.test.js',
// '<rootDir>/src/components/toaster/toaster.test.js',
// '<rootDir>/src/components/toaster/index.test.js',
// '<rootDir>/src/components/votesPreview/votesPreview.test.js',
// '<rootDir>/src/components/accountVisual/index.test.js',
// '<rootDir>/src/components/send/steps/confirm/index.test.js',
// '<rootDir>/src/components/send/steps/confim/confirm.test.js',
// '<rootDir>/src/components/box/index.test.js',
// '<rootDir>/src/components/app/index.test.js',
// '<rootDir>/src/components/secondPassphrase/index.test.js',
// '<rootDir>/src/components/secondPassphrase/secondPassphrase.test.js',
// '<rootDir>/src/components/errorBoundary/index.test.js',
// '<rootDir>/src/components/menuBar/menuBar.test.js',
// '<rootDir>/src/components/referenceInput/index.test.js',
// '<rootDir>/src/components/converter/converter.test.js',
// '<rootDir>/src/components/converter/index.test.js',
// '<rootDir>/src/components/notFound/index.test.js',
// '<rootDir>/src/components/authenticate/authenticate.test.js',
// '<rootDir>/src/components/authenticate/index.test.js',
// '<rootDir>/src/components/autoSuggest/index.test.js',
// '<rootDir>/src/components/followedAccounts/addAccountTitle.test.js',
// '<rootDir>/src/components/followedAccounts/viewAccounts.test.js',
// '<rootDir>/src/components/followedAccounts/addAccountID.test.js',
// '<rootDir>/src/components/voting/voting.test.js',
// '<rootDir>/src/components/voting/index.test.js',
// '<rootDir>/src/components/customRoute/index.test.js',
'<rootDir>/src/components/searchBar/index.test.js',
'<rootDir>/src/components/accountTransactions/index.test.js',
'<rootDir>/src/components/multiStep/index.test.js',
'<rootDir>/src/components/multiStep/multiStepNav.test.js',
'<rootDir>/src/components/fontIcon/index.test.js',
'<rootDir>/src/components/toaster/toaster.test.js',
'<rootDir>/src/components/toaster/index.test.js',
'<rootDir>/src/components/votesPreview/votesPreview.test.js',
'<rootDir>/src/components/accountVisual/index.test.js',
'<rootDir>/src/components/send/steps/confirm/index.test.js',
'<rootDir>/src/components/send/steps/confim/confirm.test.js',
'<rootDir>/src/components/box/index.test.js',
'<rootDir>/src/components/app/index.test.js',
'<rootDir>/src/components/secondPassphrase/index.test.js',
'<rootDir>/src/components/secondPassphrase/secondPassphrase.test.js',
'<rootDir>/src/components/errorBoundary/index.test.js',
'<rootDir>/src/components/menuBar/menuBar.test.js',
'<rootDir>/src/components/referenceInput/index.test.js',
'<rootDir>/src/components/converter/converter.test.js',
'<rootDir>/src/components/converter/index.test.js',
'<rootDir>/src/components/notFound/index.test.js',
'<rootDir>/src/components/authenticate/authenticate.test.js',
'<rootDir>/src/components/authenticate/index.test.js',
'<rootDir>/src/components/autoSuggest/index.test.js',
'<rootDir>/src/components/followedAccounts/addAccountTitle.test.js',
'<rootDir>/src/components/followedAccounts/viewAccounts.test.js',
'<rootDir>/src/components/followedAccounts/addAccountID.test.js',
'<rootDir>/src/components/voting/voting.test.js',
'<rootDir>/src/components/voting/index.test.js',
'<rootDir>/src/components/customRoute/index.test.js',
// '<rootDir>/src/components/passphrase/ConfirmSecond/index.test.js',
// '<rootDir>/src/components/passphrase/ConfirmSecond/confirmSecond.test.js',
// '<rootDir>/src/components/passphrase/safekeeping/index.test.js',
Expand Down Expand Up @@ -170,6 +170,7 @@ module.exports = {
'<rootDir>/test/integration/login.test.js',
],
verbose: true,
cache: false,
moduleFileExtensions: ['js'],
moduleDirectories: ['node_modules'],
moduleNameMapper: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
"electron-updater": "2.16.1",
"enzyme": "=3.1.0",
"enzyme-adapter-react-16": "=1.0.2",
"es7-object-polyfill": "0.0.7",
"eslint": "4.9.0",
"eslint-config-airbnb": "15.1.0",
"eslint-config-airbnb-base": "12.1.0",
Expand Down
4 changes: 1 addition & 3 deletions src/components/toaster/toaster.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('Toaster', () => {
let toastElement = document.getElementsByClassName('toast');

// check if the toast is activated
expect(toastElement.length > 0 &&
toastElement[0].className.indexOf('active') > 0)
.to.equal(true);
expect(toastElement.length > 0 && toastElement[0].className.indexOf('success') > 0).to.equal(true);

clock.tick(4510);

Expand Down

0 comments on commit c506ed7

Please sign in to comment.