test: extract-js-comments error
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
3e5cffba0f
commit
f6999fa8bb
@ -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}
|
||||
`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user