Skip to content

Commit

Permalink
test: test for Error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nicokaiser committed Aug 2, 2023
1 parent 6be3b04 commit c2337a3
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/limit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,48 @@ describe('limit parser', () => {
it('should throw an error for non-number strings', () => {
expect(() => {
limitParser('foo');
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
expect(() => {
limitParser({});
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
expect(() => {
limitParser([]);
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
});

it('should throw an error for strings that are isNaN, nut might be parsed by parseInt', () => {
it('should throw an error for strings that are isNaN, but might be parsed by parseInt', () => {
expect(() => {
limitParser('5;1');
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
});

it('should throw an error for non-integers', () => {
expect(() => {
limitParser(5.1);
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
expect(() => {
limitParser('5.1');
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
});

it('should throw an error for unsafe integers', () => {
expect(() => {
limitParser('999999999999999999');
}).to.throw(Error);
}).to.throw(Error, 'limit must be an integer or "unlimited"');
});

it('should throw an error for numbers < 1', () => {
expect(() => {
limitParser(0);
}).to.throw(Error);
}).to.throw(Error, 'limit must be greater than 0');
expect(() => {
limitParser('0');
}).to.throw(Error);
}).to.throw(Error, 'limit must be greater than 0');
expect(() => {
limitParser(-1);
limitParser(-1, 'limit must be greater than 0');
}).to.throw(Error);
expect(() => {
limitParser(-100);
limitParser(-100, 'limit must be greater than 0');
}).to.throw(Error);
});
});

0 comments on commit c2337a3

Please sign in to comment.