aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/actions
diff options
context:
space:
mode:
authorThomas Huang <thomas.b.huang@gmail.com>2017-05-05 05:35:10 +0800
committerThomas Huang <thomas.b.huang@gmail.com>2017-05-05 05:35:10 +0800
commit0b13429daf00ddd5bdf2705c7a95d7a9d5792f54 (patch)
treef249d8deb5fa48db54d70757de944b2c8ff76a2e /test/unit/actions
parent8f5334e4aca8b95963f57b0fbf862256b692dbd9 (diff)
downloadtangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.gz
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.tar.zst
tangerine-wallet-browser-0b13429daf00ddd5bdf2705c7a95d7a9d5792f54.zip
Lint tests
Diffstat (limited to 'test/unit/actions')
-rw-r--r--test/unit/actions/config_test.js23
-rw-r--r--test/unit/actions/save_account_label_test.js21
-rw-r--r--test/unit/actions/set_selected_account_test.js23
-rw-r--r--test/unit/actions/tx_test.js92
-rw-r--r--test/unit/actions/view_info_test.js15
-rw-r--r--test/unit/actions/warning_test.js13
6 files changed, 87 insertions, 100 deletions
diff --git a/test/unit/actions/config_test.js b/test/unit/actions/config_test.js
index 14198fa8a..648f456fb 100644
--- a/test/unit/actions/config_test.js
+++ b/test/unit/actions/config_test.js
@@ -1,36 +1,34 @@
-var jsdom = require('mocha-jsdom')
+// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
-var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-
-describe ('config view actions', function() {
+var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
+describe('config view actions', function () {
var initialState = {
metamask: {
rpcTarget: 'foo',
- frequentRpcList: []
+ frequentRpcList: [],
},
appState: {
currentView: {
name: 'accounts',
- }
- }
+ },
+ },
}
freeze(initialState)
- describe('SHOW_CONFIG_PAGE', function() {
- it('should set appState.currentView.name to config', function() {
+ describe('SHOW_CONFIG_PAGE', function () {
+ it('should set appState.currentView.name to config', function () {
var result = reducers(initialState, actions.showConfigPage())
assert.equal(result.appState.currentView.name, 'config')
})
})
- describe('SET_RPC_TARGET', function() {
-
- it('sets the state.metamask.rpcTarget property of the state to the action.value', function() {
+ describe('SET_RPC_TARGET', function () {
+ it('sets the state.metamask.rpcTarget property of the state to the action.value', function () {
const action = {
type: actions.SET_RPC_TARGET,
value: 'foo',
@@ -41,5 +39,4 @@ describe ('config view actions', function() {
assert.equal(result.metamask.provider.rpcTarget, 'foo')
})
})
-
})
diff --git a/test/unit/actions/save_account_label_test.js b/test/unit/actions/save_account_label_test.js
index 1df428b1d..c5ffd6cbf 100644
--- a/test/unit/actions/save_account_label_test.js
+++ b/test/unit/actions/save_account_label_test.js
@@ -1,22 +1,21 @@
-var jsdom = require('mocha-jsdom')
+// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
-var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
+var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-describe('SAVE_ACCOUNT_LABEL', function() {
-
- it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', function() {
+describe('SAVE_ACCOUNT_LABEL', function () {
+ it('updates the state.metamask.identities[:i].name property of the state to the action.value.label', function () {
var initialState = {
metamask: {
identities: {
foo: {
- name: 'bar'
- }
+ name: 'bar',
+ },
},
- }
+ },
}
freeze(initialState)
@@ -24,13 +23,13 @@ describe('SAVE_ACCOUNT_LABEL', function() {
type: actions.SAVE_ACCOUNT_LABEL,
value: {
account: 'foo',
- label: 'baz'
+ label: 'baz',
},
}
freeze(action)
var resultingState = reducers(initialState, action)
assert.equal(resultingState.metamask.identities.foo.name, action.value.label)
- });
-});
+ })
+})
diff --git a/test/unit/actions/set_selected_account_test.js b/test/unit/actions/set_selected_account_test.js
index 2dc42d2ec..28b47d09d 100644
--- a/test/unit/actions/set_selected_account_test.js
+++ b/test/unit/actions/set_selected_account_test.js
@@ -1,18 +1,17 @@
-var jsdom = require('mocha-jsdom')
+// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
-var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
+var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-describe('SET_SELECTED_ACCOUNT', function() {
-
- it('sets the state.appState.activeAddress property of the state to the action.value', function() {
+describe('SET_SELECTED_ACCOUNT', function () {
+ it('sets the state.appState.activeAddress property of the state to the action.value', function () {
var initialState = {
appState: {
activeAddress: 'foo',
- }
+ },
}
freeze(initialState)
@@ -24,15 +23,15 @@ describe('SET_SELECTED_ACCOUNT', function() {
var resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.activeAddress, action.value)
- });
-});
+ })
+})
-describe('SHOW_ACCOUNT_DETAIL', function() {
- it('updates metamask state', function() {
+describe('SHOW_ACCOUNT_DETAIL', function () {
+ it('updates metamask state', function () {
var initialState = {
metamask: {
- selectedAddress: 'foo'
- }
+ selectedAddress: 'foo',
+ },
}
freeze(initialState)
diff --git a/test/unit/actions/tx_test.js b/test/unit/actions/tx_test.js
index bd72a666e..0ea1bfdc7 100644
--- a/test/unit/actions/tx_test.js
+++ b/test/unit/actions/tx_test.js
@@ -1,29 +1,27 @@
-var jsdom = require('mocha-jsdom')
+// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var sinon = require('sinon')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
-var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
+var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-describe('tx confirmation screen', function() {
-
- beforeEach(function() {
- this.sinon = sinon.sandbox.create();
- });
+describe('tx confirmation screen', function () {
+ beforeEach(function () {
+ this.sinon = sinon.sandbox.create()
+ })
- afterEach(function(){
- this.sinon.restore();
- });
+ afterEach(function () {
+ this.sinon.restore()
+ })
var initialState, result
- describe('when there is only one tx', function() {
+ describe('when there is only one tx', function () {
var firstTxId = 1457634084250832
- beforeEach(function() {
-
+ beforeEach(function () {
initialState = {
appState: {
currentView: {
@@ -34,70 +32,66 @@ describe('tx confirmation screen', function() {
unapprovedTxs: {
'1457634084250832': {
id: 1457634084250832,
- status: "unconfirmed",
+ status: 'unconfirmed',
time: 1457634084250,
- }
+ },
},
- }
+ },
}
freeze(initialState)
})
- describe('cancelTx', function() {
-
- before(function(done) {
+ describe('cancelTx', function () {
+ before(function (done) {
actions._setBackgroundConnection({
- approveTransaction(txId, cb) { cb('An error!') },
- cancelTransaction(txId) { /* noop */ },
- clearSeedWordCache(cb) { cb() },
+ approveTransaction (txId, cb) { cb('An error!') },
+ cancelTransaction (txId) { /* noop */ },
+ clearSeedWordCache (cb) { cb() },
})
- let action = actions.cancelTx({value: firstTxId})
+ const action = actions.cancelTx({value: firstTxId})
result = reducers(initialState, action)
done()
})
- it('should transition to the account detail view', function() {
+ it('should transition to the account detail view', function () {
assert.equal(result.appState.currentView.name, 'accountDetail')
})
- it('should have no unconfirmed txs remaining', function() {
+ it('should have no unconfirmed txs remaining', function () {
var count = getUnconfirmedTxCount(result)
assert.equal(count, 0)
})
})
- describe('sendTx', function() {
+ describe('sendTx', function () {
var result
- describe('when there is an error', function() {
-
- before(function(done) {
- alert = () => {/* noop */}
-
+ describe('when there is an error', function () {
+ before(function (done) {
actions._setBackgroundConnection({
- approveTransaction(txId, cb) { cb({message: 'An error!'}) },
+ approveTransaction (txId, cb) { cb({message: 'An error!'}) },
})
- actions.sendTx({id: firstTxId})(function(action) {
+ actions.sendTx({id: firstTxId})(function (action) {
result = reducers(initialState, action)
done()
})
})
- it('should stay on the page', function() {
+ it('should stay on the page', function () {
assert.equal(result.appState.currentView.name, 'confTx')
})
- it('should set errorMessage on the currentView', function() {
+ it('should set errorMessage on the currentView', function () {
assert(result.appState.currentView.errorMessage)
})
})
- describe('when there is success', function() {
- it('should complete tx and go home', function() {
+ describe('when there is success', function () {
+ it('should complete tx and go home', function () {
actions._setBackgroundConnection({
- approveTransaction(txId, cb) { cb() },
+ approveTransaction (txId, cb) { cb() },
})
var dispatchExpect = sinon.mock()
@@ -108,10 +102,10 @@ describe('tx confirmation screen', function() {
})
})
- describe('when there are two pending txs', function() {
+ describe('when there are two pending txs', function () {
var firstTxId = 1457634084250832
var result, initialState
- before(function(done) {
+ before(function (done) {
initialState = {
appState: {
currentView: {
@@ -122,42 +116,42 @@ describe('tx confirmation screen', function() {
unapprovedTxs: {
'1457634084250832': {
id: firstTxId,
- status: "unconfirmed",
+ status: 'unconfirmed',
time: 1457634084250,
},
'1457634084250833': {
id: 1457634084250833,
- status: "unconfirmed",
+ status: 'unconfirmed',
time: 1457634084255,
},
},
- }
+ },
}
freeze(initialState)
// Mocking a background connection:
actions._setBackgroundConnection({
- approveTransaction(firstTxId, cb) { cb() },
+ approveTransaction (firstTxId, cb) { cb() },
})
- let action = actions.sendTx({id: firstTxId})(function(action) {
+ actions.sendTx({id: firstTxId})(function (action) {
result = reducers(initialState, action)
})
done()
})
- it('should stay on the confTx view', function() {
+ it('should stay on the confTx view', function () {
assert.equal(result.appState.currentView.name, 'confTx')
})
- it('should transition to the first tx', function() {
+ it('should transition to the first tx', function () {
assert.equal(result.appState.currentView.context, 0)
})
})
})
-});
+})
-function getUnconfirmedTxCount(state) {
+function getUnconfirmedTxCount (state) {
var txs = state.metamask.unapprovedTxs
var count = Object.keys(txs).length
return count
diff --git a/test/unit/actions/view_info_test.js b/test/unit/actions/view_info_test.js
index 0558c6e42..69895d801 100644
--- a/test/unit/actions/view_info_test.js
+++ b/test/unit/actions/view_info_test.js
@@ -1,23 +1,22 @@
-var jsdom = require('mocha-jsdom')
+// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
-var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
+var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-describe('SHOW_INFO_PAGE', function() {
-
- it('sets the state.appState.currentView.name property to info', function() {
+describe('SHOW_INFO_PAGE', function () {
+ it('sets the state.appState.currentView.name property to info', function () {
var initialState = {
appState: {
activeAddress: 'foo',
- }
+ },
}
freeze(initialState)
const action = actions.showInfoPage()
var resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.currentView.name, 'info')
- });
-});
+ })
+})
diff --git a/test/unit/actions/warning_test.js b/test/unit/actions/warning_test.js
index 37be9ee85..28b565499 100644
--- a/test/unit/actions/warning_test.js
+++ b/test/unit/actions/warning_test.js
@@ -1,14 +1,13 @@
-var jsdom = require('mocha-jsdom')
+// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
-var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
+var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-describe('action DISPLAY_WARNING', function() {
-
- it('sets appState.warning to provided value', function() {
+describe('action DISPLAY_WARNING', function () {
+ it('sets appState.warning to provided value', function () {
var initialState = {
appState: {},
}
@@ -20,5 +19,5 @@ describe('action DISPLAY_WARNING', function() {
const resultingState = reducers(initialState, action)
assert.equal(resultingState.appState.warning, warningText, 'warning text set')
- });
-});
+ })
+})