diff --git a/.eslintrc b/.eslintrc index 731f31522..3c8bb7a72 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,7 +39,14 @@ "no-restricted-properties": "off", "no-return-assign": "off", "no-underscore-dangle": "off", - "import/no-extraneous-dependencies": "off", + "import/no-extraneous-dependencies": ["error", { + devDependencies: [ + "./src/**/*.test.js", + "./features/*/*.js", + "./src/**/stories.js" + ] + } + ], "no-param-reassign": "off" } } diff --git a/Jenkinsfile b/Jenkinsfile index 719b93495..43993dee4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,15 +42,37 @@ node('lisk-nano-01'){ } } - stage ('Build Nano') { + stage ('Install npm dependencies') { try { sh '''#!/bin/bash - # Install Electron npm install # Build nano cd $WORKSPACE npm install + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + milestone 1 + error('Stopping build, npm install failed') + } + } + + stage ('Run Eslint') { + try { + sh ''' + cd $WORKSPACE + npm run eslint + ''' + } catch (err) { + currentBuild.result = 'FAILURE' + error('Stopping build, Eslint failed') + } + } + + stage ('Build Nano') { + try { + sh '''#!/bin/bash # Add coveralls config file cp ~/.coveralls.yml-nano .coveralls.yml diff --git a/features/step_definitions/forging.step.js b/features/step_definitions/forging.step.js index 193386f73..9de1a033a 100644 --- a/features/step_definitions/forging.step.js +++ b/features/step_definitions/forging.step.js @@ -1,7 +1,7 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const { waitForElemAndCheckItsText } = require('../support/util.js'); - defineSupportCode(({ Then }) => { Then('I should see forging center', (callback) => { waitForElemAndCheckItsText('.delegate-name', 'genesis_17', callback); diff --git a/features/step_definitions/generic.step.js b/features/step_definitions/generic.step.js index a6df04d8f..0ba8096fd 100644 --- a/features/step_definitions/generic.step.js +++ b/features/step_definitions/generic.step.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); @@ -114,9 +115,8 @@ defineSupportCode(({ Given, When, Then, setDefaultTimeout }) => { * Generates a sequence of random pairs of x,y coordinates on the screen that simulates * the movement of mouse to produce a pass phrase. */ - for (let i = 0; i < iterations; i++) { - actions - .mouseMove(element(by.css('body')), { + for (let i = 0; i < iterations; i += 1) { + actions.mouseMove(element(by.css('body')), { x: 500 + (Math.floor((((i % 2) * 2) - 1) * (249 + (Math.random() * 250)))), y: 500 + (Math.floor((((i % 2) * 2) - 1) * (249 + (Math.random() * 250)))), }); diff --git a/features/step_definitions/hooks.js b/features/step_definitions/hooks.js index e41604ec8..fbe42fa4b 100644 --- a/features/step_definitions/hooks.js +++ b/features/step_definitions/hooks.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const fs = require('fs'); diff --git a/features/step_definitions/login.step.js b/features/step_definitions/login.step.js index 42ee984b1..b1146bfc3 100644 --- a/features/step_definitions/login.step.js +++ b/features/step_definitions/login.step.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const { waitForElemAndCheckItsText } = require('../support/util.js'); diff --git a/features/step_definitions/menu.step.js b/features/step_definitions/menu.step.js index caf0d00e7..163ba0ca8 100644 --- a/features/step_definitions/menu.step.js +++ b/features/step_definitions/menu.step.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); diff --git a/features/step_definitions/top.step.js b/features/step_definitions/top.step.js index 2f37b8504..9d89fe52e 100644 --- a/features/step_definitions/top.step.js +++ b/features/step_definitions/top.step.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const { waitForElemAndCheckItsText } = require('../support/util.js'); diff --git a/features/step_definitions/transactions.step.js b/features/step_definitions/transactions.step.js index 48ebcd098..cfb2fee7d 100644 --- a/features/step_definitions/transactions.step.js +++ b/features/step_definitions/transactions.step.js @@ -1,7 +1,7 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const { waitForElemAndClickIt } = require('../support/util.js'); - defineSupportCode(({ When }) => { When('I click "{elementName}" element on table row no. {index}', (elementName, index, callback) => { const selectorClass = `.${elementName.replace(/ /g, '-')}`; diff --git a/features/step_definitions/voting.step.js b/features/step_definitions/voting.step.js index ba6dcf7bc..e326edd4d 100644 --- a/features/step_definitions/voting.step.js +++ b/features/step_definitions/voting.step.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const { defineSupportCode } = require('cucumber'); const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); diff --git a/features/support/util.js b/features/support/util.js index 8dce966a4..a9b5ad31d 100644 --- a/features/support/util.js +++ b/features/support/util.js @@ -1,3 +1,4 @@ +/* eslint-disable import/no-extraneous-dependencies */ const chai = require('chai'); const chaiAsPromised = require('chai-as-promised'); diff --git a/package.json b/package.json index 90a5d76b7..78f28462e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "dist:linux": "build --linux --ia32 --x64 --armv7l", "copy-files": "mkdir dist && cp -r ./src/index.html ./src/assets ./dist", "clean": "del dist -f", + "eslint": "eslint ./src/ ./app/ ./features/", "storybook": "start-storybook -p 6006 -s ./src/", "build-storybook": "build-storybook" }, @@ -40,14 +41,18 @@ "react": "=15.6.x", "react-animate-on-change": "^1.0.0", "react-circular-progressbar": "=0.1.5", + "react-css-themr": "=2.1.2", "react-dom": "=15.6.x", "react-redux": "=5.0.5", + "react-router": "=4.1.2", "react-router-dom": "=4.1.2", "react-toolbox": "=2.0.0-beta.12", + "react-waypoint": "=7.0.4", "redux": "=3.6.0", "redux-logger": "=3.0.6" }, "devDependencies": { + "@storybook/addon-actions": "=3.2.0", "@storybook/react": "=3.1.8", "babel-core": "=6.20.0", "babel-loader": "=7.0.0-beta.1", @@ -98,7 +103,6 @@ "react-addons-test-utils": "=15.6.0", "react-hot-loader": "^1.3.1", "react-test-renderer": "=15.6.1", - "react-waypoint": "^7.0.4", "redux-mock-store": "=1.2.3", "should": "=11.2.0", "sinon": "=2.0.0", diff --git a/src/components/account/stories.js b/src/components/account/stories.js index 2afe1ab26..374c02e78 100644 --- a/src/components/account/stories.js +++ b/src/components/account/stories.js @@ -1,38 +1,44 @@ import React from 'react'; +import { Provider } from 'react-redux'; import { storiesOf } from '@storybook/react'; -import Account from './accountComponent'; +import Account from './account'; import Address from './address'; +import store from '../../store'; storiesOf('Account', module) .add('delegate', () => ( - + + data: { + options: { + name: 'testy', + }, + currentPeer: 'testpeer', + port: 8000, + }, + }} + account={{ + isDelegate: true, + address: '9396639332432599292L', + delegate: { + username: 'testy', + }, + }} + balance="3.1415926535" + /> + )); storiesOf('Address', module) .add('delegate', () => (
)) diff --git a/src/components/registerDelegate/registerDelegate.test.js b/src/components/registerDelegate/registerDelegate.test.js index cda8d75b6..3f7672050 100644 --- a/src/components/registerDelegate/registerDelegate.test.js +++ b/src/components/registerDelegate/registerDelegate.test.js @@ -88,7 +88,7 @@ describe('RegisterDelegate', () => { it('allows register as delegate for a non delegate account', () => { delegateApiMock.expects('registerDelegate').resolves({ success: true }); wrapper.find('.username input').simulate('change', { target: { value: 'sample_username' } }); - wrapper.find('.next-button').simulate('click') + wrapper.find('.next-button').simulate('click'); expect(wrapper.find('.primary-button button').props().disabled).to.not.equal(true); // TODO: this doesn't work for some reason // expect(props.showSuccessAlert).to.have.been.calledWith(); @@ -98,7 +98,7 @@ describe('RegisterDelegate', () => { const message = 'Username already exists'; delegateApiMock.expects('registerDelegate').rejects({ message }); wrapper.find('.username input').simulate('change', { target: { value: 'sample_username' } }); - wrapper.find('.next-button').simulate('click') + wrapper.find('.next-button').simulate('click'); // TODO: this doesn't work for some reason // expect(wrapper.find('RegisterDelegate .username').text()).to.contain(message); }); @@ -106,7 +106,7 @@ describe('RegisterDelegate', () => { it('handles register as delegate failure', () => { delegateApiMock.expects('registerDelegate').rejects({ success: false }); wrapper.find('.username input').simulate('change', { target: { value: 'sample_username' } }); - wrapper.find('.next-button').simulate('click') + wrapper.find('.next-button').simulate('click'); expect(wrapper.find('.primary-button button').props().disabled).to.not.equal(true); // TODO: this doesn't work for some reason // expect(props.showErrorAlert).to.have.been.calledWith(); diff --git a/src/components/secondPassphrase/index.test.js b/src/components/secondPassphrase/index.test.js index 57c6ca935..af16e3c03 100644 --- a/src/components/secondPassphrase/index.test.js +++ b/src/components/secondPassphrase/index.test.js @@ -5,7 +5,6 @@ import sinonChai from 'sinon-chai'; import { mount } from 'enzyme'; import chaiEnzyme from 'chai-enzyme'; import { Provider } from 'react-redux'; -import * as accountActions from '../../actions/account'; import * as transactionsActions from '../../actions/transactions'; import * as dialogActions from '../../actions/dialog'; import store from '../../store'; @@ -59,15 +58,14 @@ describe('SecondPassphrase', () => { }); describe('SecondPassphraseConnected', () => { - let wrapper; - let props; + let childProps; store.getState = () => ({ - account: { secondSignature: 1 } + account: { secondSignature: 1 }, }); beforeEach(() => { - wrapper = mount(); - props = wrapper.find(SecondPassphrase).props(); + wrapper = mount(); + childProps = wrapper.find(SecondPassphrase).props(); }); it('should render SecondPassphrase', () => { @@ -76,21 +74,21 @@ describe('SecondPassphrase', () => { it('should bind dialogDisplayed action to SecondPassphrase props.setActiveDialog', () => { const actionsSpy = sinon.spy(dialogActions, 'dialogDisplayed'); - props.setActiveDialog({}); + childProps.setActiveDialog({}); expect(actionsSpy).to.be.calledWith(); actionsSpy.restore(); }); it('should bind successAlertDialogDisplayed action to SecondPassphrase props.showSuccessAlert', () => { const actionsSpy = sinon.spy(dialogActions, 'successAlertDialogDisplayed'); - props.showSuccessAlert({}); + childProps.showSuccessAlert({}); expect(actionsSpy).to.be.calledWith(); actionsSpy.restore(); }); it('should bind transactionAdded action to SecondPassphrase props.addTransaction', () => { const actionsSpy = sinon.spy(transactionsActions, 'transactionAdded'); - props.addTransaction({}); + childProps.addTransaction({}); expect(actionsSpy).to.be.calledWith(); actionsSpy.restore(); });