Skip to content

Commit

Permalink
Change try/catch statement to chai throw method
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleh Momot committed May 6, 2020
1 parent aa11036 commit c432f99
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions ilc/client/handlePageTransaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,15 @@ describe('handle page transaction', () => {
});

it('should throw an error when a slot name is not provided', async () => {
let caughtError;

try {
handlePageTransaction();
} catch(error) {
caughtError = error;
}

chai.expect(caughtError).to.be.an.instanceof(Error);
chai.expect(caughtError.message).to.be.eql('A slot name was not provided!');
chai.expect(() => handlePageTransaction()).to.throw(
'A slot name was not provided!'
);
});

it('should throw an error when a slot action does not match any possible option to handle', async () => {
let caughtError;

try {
handlePageTransaction(slots.body.id, 'undefined');
} catch(error) {
caughtError = error;
}

chai.expect(caughtError).to.be.an.instanceof(Error);
chai.expect(caughtError.message).to.be.eql(`The slot action 'undefined' did not match any possible values!`);
chai.expect(() => handlePageTransaction(slots.body.id, 'undefined')).to.throw(
`The slot action 'undefined' did not match any possible values!`
);
});

it('should do nothing when a slot action is default', async () => {
Expand Down

0 comments on commit c432f99

Please sign in to comment.