Skip to content

Commit 794ab08

Browse files
committed
chore: improve code cov
# Conflicts: # src/__tests__/compiler.test.tsx
1 parent 1eb5f66 commit 794ab08

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/__tests__/compiler.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ test('"buildPattern" escapes special characters', () => {
4949
'(?:\\.\\*)+(?:\\[\\]\\{\\})*'
5050
);
5151
});
52+
53+
test('buildRegex throws error on unknown element', () => {
54+
expect(() =>
55+
// @ts-expect-error intentionally passing incorrect object
56+
buildRegex({ type: 'unknown' })
57+
).toThrowErrorMatchingInlineSnapshot(`"Unknown elements type unknown"`);
58+
});

src/compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ function compileSingle(element: RegexElement): string {
3939
return characterClasses[element.type];
4040
}
4141

42-
const compiledChildren = compileList(element.children);
43-
4442
if (element.type === 'repeat') {
43+
const compiledChildren = compileList(element.children);
4544
return compileRepeat(element.config, compiledChildren);
4645
}
4746

4847
if (isBaseQuantifier(element)) {
48+
const compiledChildren = compileList(element.children);
4949
const compiler = baseQuantifiers[element.type];
5050
return compiler(compiledChildren);
5151
}

0 commit comments

Comments
 (0)