From 29c332b7e39d2c9aa028dbe784763b64eeaf651c Mon Sep 17 00:00:00 2001 From: scripthunter7 Date: Tue, 17 Oct 2023 11:26:34 +0200 Subject: [PATCH] Test all possible errors --- .../test/css-tokenizer/errors.test.ts | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/packages/css-tokenizer/test/css-tokenizer/errors.test.ts b/packages/css-tokenizer/test/css-tokenizer/errors.test.ts index 38b718509..f8ea62a43 100644 --- a/packages/css-tokenizer/test/css-tokenizer/errors.test.ts +++ b/packages/css-tokenizer/test/css-tokenizer/errors.test.ts @@ -16,7 +16,60 @@ describe('onError callback', () => { [ErrorMessage.UnterminatedComment, 0, 18], ], }, - // FIXME: Test all possible errors + { + actual: '"eof in string', + expected: [ + [ErrorMessage.UnexpectedEofInString, 0, 14], + ], + }, + { + actual: '"eof in string\\', + expected: [ + [ErrorMessage.UnexpectedEofInString, 0, 15], + ], + }, + { + actual: '"newline in string\n', + expected: [ + [ErrorMessage.UnexpectedNewlineInString, 0, 19], + ], + }, + { + actual: 'url(eof-in-url', + expected: [ + [ErrorMessage.UnexpectedEofInUrl, 0, 14], + ], + }, + { + actual: 'url( ', + expected: [ + [ErrorMessage.UnexpectedEofInUrl, 0, 6], + ], + }, + { + actual: 'url(a a)', + expected: [ + [ErrorMessage.UnexpectedCharInUrl, 0, 6], + ], + }, + { + actual: 'url(aa"', + expected: [ + [ErrorMessage.UnexpectedCharInUrl, 0, 6], + ], + }, + { + actual: "url(aa'", + expected: [ + [ErrorMessage.UnexpectedCharInUrl, 0, 6], + ], + }, + { + actual: 'url(\\\n', + expected: [ + [ErrorMessage.UnexpectedCharInUrl, 0, 4], + ], + }, ])('should report error for \'$actual\'', ({ actual, expected }) => { const errors: ErrorData[] = []; tokenize(actual, () => {}, (...args) => errors.push(args));