diff options
author | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-15 04:56:53 +0800 |
---|---|---|
committer | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-15 04:56:53 +0800 |
commit | 5aba096bd1afe23cf3df491ef67e24858e6efc01 (patch) | |
tree | 553e31da9ea77c0f3811079e3631fb5ecb1c248b /test/unit/config-manager-test.js | |
parent | 090935f90aa3c2589fee7bc038c8f4fcf77da03c (diff) | |
download | tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.tar tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.tar.gz tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.tar.bz2 tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.tar.lz tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.tar.xz tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.tar.zst tangerine-wallet-browser-5aba096bd1afe23cf3df491ef67e24858e6efc01.zip |
add Test for txManager. As well as fix tests to account for txManager.
Diffstat (limited to 'test/unit/config-manager-test.js')
-rw-r--r-- | test/unit/config-manager-test.js | 83 |
1 files changed, 3 insertions, 80 deletions
diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js index 206460ffb..61226d624 100644 --- a/test/unit/config-manager-test.js +++ b/test/unit/config-manager-test.js @@ -215,7 +215,7 @@ describe('config-manager', function() { describe('transactions', function() { beforeEach(function() { - configManager._saveTxList([]) + configManager.setTxList([]) }) describe('#getTxList', function() { @@ -226,90 +226,13 @@ describe('config-manager', function() { }) }) - describe('#_saveTxList', function() { + describe('#setTxList', function() { it('saves the submitted data to the tx list', function() { var target = [{ foo: 'bar' }] - configManager._saveTxList(target) + configManager.setTxList(target) var result = configManager.getTxList() assert.equal(result[0].foo, 'bar') }) }) - - describe('#addTx', function() { - it('adds a tx returned in getTxList', function() { - var tx = { id: 1 } - configManager.addTx(tx) - var result = configManager.getTxList() - assert.ok(Array.isArray(result)) - assert.equal(result.length, 1) - assert.equal(result[0].id, 1) - }) - - it('cuts off early txs beyond a limit', function() { - const limit = configManager.txLimit - for (let i = 0; i < limit + 1; i++) { - let tx = { id: i } - configManager.addTx(tx) - } - var result = configManager.getTxList() - assert.equal(result.length, limit, `limit of ${limit} txs enforced`) - assert.equal(result[0].id, 1, 'early txs truncted') - }) - }) - - describe('#confirmTx', function() { - it('sets the tx status to confirmed', function() { - var tx = { id: 1, status: 'unconfirmed' } - configManager.addTx(tx) - configManager.confirmTx(1) - var result = configManager.getTxList() - assert.ok(Array.isArray(result)) - assert.equal(result.length, 1) - assert.equal(result[0].status, 'confirmed') - }) - }) - - describe('#rejectTx', function() { - it('sets the tx status to rejected', function() { - var tx = { id: 1, status: 'unconfirmed' } - configManager.addTx(tx) - configManager.rejectTx(1) - var result = configManager.getTxList() - assert.ok(Array.isArray(result)) - assert.equal(result.length, 1) - assert.equal(result[0].status, 'rejected') - }) - }) - - describe('#updateTx', function() { - it('replaces the tx with the same id', function() { - configManager.addTx({ id: '1', status: 'unconfirmed' }) - configManager.addTx({ id: '2', status: 'confirmed' }) - configManager.updateTx({ id: '1', status: 'blah', hash: 'foo' }) - var result = configManager.getTx('1') - assert.equal(result.hash, 'foo') - }) - }) - - describe('#unconfirmedTxs', function() { - it('returns unconfirmed txs in a hash', function() { - configManager.addTx({ id: '1', status: 'unconfirmed' }) - configManager.addTx({ id: '2', status: 'confirmed' }) - let result = configManager.unconfirmedTxs() - assert.equal(typeof result, 'object') - assert.equal(result['1'].status, 'unconfirmed') - assert.equal(result['0'], undefined) - assert.equal(result['2'], undefined) - }) - }) - - describe('#getTx', function() { - it('returns a tx with the requested id', function() { - configManager.addTx({ id: '1', status: 'unconfirmed' }) - configManager.addTx({ id: '2', status: 'confirmed' }) - assert.equal(configManager.getTx('1').status, 'unconfirmed') - assert.equal(configManager.getTx('2').status, 'confirmed') - }) - }) }) }) |