Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
♻️ Update error catch syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Sep 13, 2018
1 parent dfe65c8 commit 3a59cd1
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 39 deletions.
28 changes: 14 additions & 14 deletions test/commands/transaction/broadcast.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ describe('transaction:broadcast', () => {
sandbox.stub().rejects(new Error('Timeout error')),
)
.command(['transaction:broadcast'])
.catch(error =>
expect(error.message).to.contain('No transaction was provided.'),
)
.catch(error => {
return expect(error.message).to.contain('No transaction was provided.');
})
.it('should throw an error without transaction');
});

describe('transaction:broadcast transaction', () => {
setupTest()
.command(['transaction:broadcast', wrongTransaction])
.catch(error =>
expect(error.message).to.contain(
.catch(error => {
return expect(error.message).to.contain(
'Could not parse transaction JSON. Did you use the `--json` option?',
),
)
);
})
.it('should throw an error with invalid transaction');

setupTest()
Expand All @@ -96,9 +96,9 @@ describe('transaction:broadcast', () => {
setupTest()
.stub(inputUtils, 'getRawStdIn', sandbox.stub().resolves([]))
.command(['transaction:broadcast'])
.catch(error =>
expect(error.message).to.contain('No transaction was provided.'),
)
.catch(error => {
return expect(error.message).to.contain('No transaction was provided.');
})
.it('should throw an error with invalid transaction from stdin');

setupTest()
Expand All @@ -108,11 +108,11 @@ describe('transaction:broadcast', () => {
sandbox.stub().resolves(wrongTransaction),
)
.command(['transaction:broadcast'])
.catch(error =>
expect(error.message).to.contain(
.catch(error => {
return expect(error.message).to.contain(
'Could not parse transaction JSON. Did you use the `--json` option?',
),
)
);
})
.it('should throw an error with invalid transaction from stdin');

setupTest()
Expand Down
4 changes: 3 additions & 1 deletion test/commands/transaction/get.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ describe('transaction:get', () => {

setupTest()
.command(['transaction:get'])
.catch(error => expect(error.message).to.contain('Missing 1 required arg'))
.catch(error => {
return expect(error.message).to.contain('Missing 1 required arg');
})
.it('should throw an error when arg is not provided');

describe('transaction:get transaction', () => {
Expand Down
28 changes: 16 additions & 12 deletions test/commands/transaction/sign.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ describe('transaction:sign', () => {
sandbox.stub().rejects(new Error('Timeout error')),
)
.command(['transaction:sign'])
.catch(error =>
expect(error.message).to.contain('No transaction was provided.'),
)
.catch(error => {
return expect(error.message).to.contain('No transaction was provided.');
})
.it('should throw an error');
});

describe('transaction:sign transaction', () => {
setupTest()
.command(['transaction:sign', invalidTransaction])
.catch(error =>
expect(error.message).to.contain('Could not parse transaction JSON.'),
)
.catch(error => {
return expect(error.message).to.contain(
'Could not parse transaction JSON.',
);
})
.it('should throw an error');

setupTest()
Expand Down Expand Up @@ -171,9 +173,9 @@ describe('transaction:sign', () => {
setupTest()
.stub(inputUtils, 'getRawStdIn', sandbox.stub().resolves([]))
.command(['transaction:sign'])
.catch(error =>
expect(error.message).to.contain('No transaction was provided.'),
)
.catch(error => {
return expect(error.message).to.contain('No transaction was provided.');
})
.it('should throw an error when stdin is empty');

setupTest()
Expand All @@ -183,9 +185,11 @@ describe('transaction:sign', () => {
sandbox.stub().resolves([invalidTransaction]),
)
.command(['transaction:sign'])
.catch(error =>
expect(error.message).to.contain('Could not parse transaction JSON.'),
)
.catch(error => {
return expect(error.message).to.contain(
'Could not parse transaction JSON.',
);
})
.it('should throw an error when std is an invalid JSON format');

setupTest()
Expand Down
28 changes: 16 additions & 12 deletions test/commands/transaction/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ describe('transaction:verify', () => {
sandbox.stub().rejects(new Error('Timeout error')),
)
.command(['transaction:verify'])
.catch(error =>
expect(error.message).to.contain('No transaction was provided.'),
)
.catch(error => {
return expect(error.message).to.contain('No transaction was provided.');
})
.it('should throw an error');
});

describe('transaction:verify transaction', () => {
setupTest()
.command(['transaction:verify', invalidTransaction])
.catch(error =>
expect(error.message).to.contain('Could not parse transaction JSON.'),
)
.catch(error => {
return expect(error.message).to.contain(
'Could not parse transaction JSON.',
);
})
.it('should throw an error');

setupTest()
Expand Down Expand Up @@ -133,9 +135,9 @@ describe('transaction:verify', () => {
setupTest()
.stub(inputUtils, 'getRawStdIn', sandbox.stub().resolves([]))
.command(['transaction:verify'])
.catch(error =>
expect(error.message).to.contain('No transaction was provided.'),
)
.catch(error => {
return expect(error.message).to.contain('No transaction was provided.');
})
.it('should throw an error when no stdin was provided');

setupTest()
Expand All @@ -145,9 +147,11 @@ describe('transaction:verify', () => {
sandbox.stub().resolves([invalidTransaction]),
)
.command(['transaction:verify'])
.catch(error =>
expect(error.message).to.contain('Could not parse transaction JSON.'),
)
.catch(error => {
return expect(error.message).to.contain(
'Could not parse transaction JSON.',
);
})
.it('should throw an error when invalid JSON format was provided');

setupTest()
Expand Down

0 comments on commit 3a59cd1

Please sign in to comment.