Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from martialblog/validate-errorhandling
Browse files Browse the repository at this point in the history
Change Errorhandling for validate function
  • Loading branch information
martialblog committed Feb 19, 2018
2 parents e9e22d6 + 808967e commit 88f23ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function (input) {
}

if (!lib.validParentheses(input)) {
throw new SyntaxError('Invalid input. Missmatched parentheses');
return valid;
}

str = lib.sanitizeWhitespaces(input);
Expand Down
10 changes: 7 additions & 3 deletions test/validate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ test('Throws TypeError with no String', () => {
expect(failMe).toThrow(TypeError);
});

test('Throws SyntaxError at mismatch', () => {
function failMe() {validate('{close me')}
expect(failMe).toThrow(SyntaxError);
test('Testing parentheses mismatch', () => {
expect(validate('[')).toBe(false);
expect(validate('{')).toBe(false);
expect(validate('(')).toBe(false);
expect(validate('}')).toBe(false);
expect(validate('}')).toBe(false);
expect(validate(')')).toBe(false);
});

test('Testing validate lemma', () => {
Expand Down

0 comments on commit 88f23ee

Please sign in to comment.