test: extract-js-comments error

This commit is contained in:
Oliver Eyton-Williams
2021-10-27 16:32:37 +02:00
committed by Mrugesh Mohapatra
parent 3e5cffba0f
commit f6999fa8bb

View File

@ -13,6 +13,8 @@ var y = '// single line comment';
`;
const someInvalidJS = `const isChange;`;
describe('extractJSComments', () => {
it('should return an object with comment keys and count values', () => {
const commentCounts = {
@ -21,4 +23,13 @@ describe('extractJSComments', () => {
};
expect(extractJSComments(someJS)).toEqual(commentCounts);
});
it('should throw an informative error if the JS is invalid', () => {
expect(() => extractJSComments(someInvalidJS)).toThrow(
`extract-js-comments could not parse the code below, this challenge have invalid syntax:
${someInvalidJS}
`
);
});
});