generated from archoleat/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { describe, expect, test as spec } from 'bun:test'; | ||
import { FONT_FILE_NAME_REGEX } from '#src/index.ts'; | ||
|
||
describe('FONT_FILE_NAME_REGEX', () => { | ||
const validTestCases = [ | ||
'Roboto-Bold.otf', | ||
'OpenSans-Light.ttf', | ||
'Montserrat-ExtraBold.woff', | ||
'Lato-Regular.woff2', | ||
'Roboto-BoldItalic.otf', | ||
'OpenSans-LightVariable.ttf', | ||
'Montserrat-ExtraBoldItalicVariable.woff', | ||
'Lato-RegularVariable.woff2', | ||
]; | ||
|
||
validTestCases.forEach((testCase) => { | ||
spec(`should match valid font file name: ${testCase}`, () => { | ||
expect(testCase).toMatch(FONT_FILE_NAME_REGEX); | ||
}); | ||
}); | ||
|
||
const invalidTestCases = [ | ||
'Roboto-Bold', | ||
'OpenSans-Light.pdf', | ||
'Montserrat-ExtraBoldItalic', | ||
'Lato-RegularVariable', | ||
'Roboto-Bold.otf.ttf', | ||
'OpenSans-Light.ttf.woff', | ||
'Montserrat-ExtraBoldItalicVariable', | ||
'Lato-RegularVariable.woff2.ttf', | ||
'Roboto-Bold.otf ', | ||
' OpenSans-Light.ttf', | ||
]; | ||
|
||
invalidTestCases.forEach((testCase) => { | ||
spec(`should not match invalid font file name: ${testCase}`, () => { | ||
expect(testCase).not.toMatch(FONT_FILE_NAME_REGEX); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,136 @@ | ||
import { describe, expect, test as spec } from 'bun:test'; | ||
|
||
import { NESTED_ATTRIBUTE_REGEX, NESTED_CLASS_REGEX } from '#src/index.ts'; | ||
import { | ||
NESTED_ATTRIBUTE_REGEX, | ||
NESTED_CLASS_REGEX, | ||
NESTED_MODIFIER_REGEX, | ||
NESTED_ELEMENT_REGEX, | ||
ATTRIBUTE_REGEX, | ||
CLASS_REGEX, | ||
MODIFIER_REGEX, | ||
ELEMENT_REGEX, | ||
SIBLING_REGEX, | ||
CHILD_REGEX, | ||
ATTRIBUTE_SIBLING_REGEX, | ||
ATTRIBUTE_CHILD_REGEX, | ||
CLASS_SIBLING_REGEX, | ||
CLASS_CHILD_REGEX, | ||
NESTED_ATTRIBUTE_SIBLING_REGEX, | ||
NESTED_ATTRIBUTE_CHILD_REGEX, | ||
NESTED_CLASS_SIBLING_REGEX, | ||
NESTED_CLASS_CHILD_REGEX, | ||
} from '#src/index.ts'; | ||
|
||
describe('Nested Selectors Regex', async () => { | ||
spec('should &[attribute]', async () => { | ||
spec('should match &[attribute]', async () => { | ||
expect('&[attribute]').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute] {}', async () => { | ||
expect('&[attribute] {}').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute=value]', async () => { | ||
spec('should match &[attribute=value]', async () => { | ||
expect('&[attribute=value]').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute*=value]', async () => { | ||
spec('should match &[attribute*=value]', async () => { | ||
expect('&[attribute*=value]').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute=value] {}', async () => { | ||
expect('&[attribute=value] {}').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match &[attribute="value"]', async () => { | ||
expect('&[attribute="value"]').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute*=value] {}', async () => { | ||
expect('&[attribute*=value] {}').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match &[attribute*="value"]', async () => { | ||
expect('&[attribute*="value"]').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec("&[attribute='value']", async () => { | ||
spec("should match &[attribute='value']", async () => { | ||
expect("&[attribute='value']").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute*="value"]', async () => { | ||
expect('&[attribute*="value"]').toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec("should match &[attribute*='value']", async () => { | ||
expect("&[attribute*='value']").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute="value"] {}', async () => { | ||
expect("&[attribute='value'] {}").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match &.class', async () => { | ||
expect('&.class').toMatch(new RegExp(NESTED_CLASS_REGEX)); | ||
}); | ||
|
||
spec('should &[attribute*="value"] {}', async () => { | ||
expect("&[attribute*='value'] {}").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match &--modifier', async () => { | ||
expect('&--modifier').toMatch(new RegExp(NESTED_MODIFIER_REGEX)); | ||
}); | ||
|
||
spec("&[attribute='value']", async () => { | ||
expect("&[attribute='value']").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match &__element', async () => { | ||
expect('&__element').toMatch(new RegExp(NESTED_ELEMENT_REGEX)); | ||
}); | ||
|
||
spec("&[attribute*='value']", async () => { | ||
expect("&[attribute*='value']").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match [attribute]', async () => { | ||
expect('[attribute]').toMatch(new RegExp(ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec("&[attribute='value'] {}", async () => { | ||
expect("&[attribute='value'] {}").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match [attribute=value]', async () => { | ||
expect('[attribute=value]').toMatch(new RegExp(ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec("&[attribute*='value'] {}", async () => { | ||
expect("&[attribute*='value'] {}").toMatch(new RegExp(NESTED_ATTRIBUTE_REGEX)); | ||
spec('should match [attribute*=value]', async () => { | ||
expect('[attribute*=value]').toMatch(new RegExp(ATTRIBUTE_REGEX)); | ||
}); | ||
|
||
spec('should &.class', async () => { | ||
expect('&.class').toMatch(new RegExp(NESTED_CLASS_REGEX)); | ||
spec('should match .class', async () => { | ||
expect('.class').toMatch(new RegExp(CLASS_REGEX)); | ||
}); | ||
|
||
spec('should &.class {}', async () => { | ||
expect('&.class {}').toMatch(new RegExp(NESTED_CLASS_REGEX)); | ||
spec('should match --modifier', async () => { | ||
expect('--modifier').toMatch(new RegExp(MODIFIER_REGEX)); | ||
}); | ||
|
||
// spec('should &--modifier', async () => { | ||
// expect('&--modifier').toMatch(new RegExp(MODIFIER_REGEX)); | ||
// }); | ||
spec('should match __element', async () => { | ||
expect('__element').toMatch(new RegExp(ELEMENT_REGEX)); | ||
}); | ||
|
||
spec('should match sibling selector', async () => { | ||
expect('+ p').toMatch(new RegExp(SIBLING_REGEX)); | ||
}); | ||
|
||
spec('should match child selector', async () => { | ||
expect('> p').toMatch(new RegExp(CHILD_REGEX)); | ||
}); | ||
|
||
spec('should match sibling selector', async () => { | ||
expect('div + p').toMatch(new RegExp(SIBLING_REGEX)); | ||
}); | ||
|
||
// spec('should &--modifier {}', async () => { | ||
// expect('&--modifier {}').toMatch(new RegExp(MODIFIER_REGEX)); | ||
// }); | ||
spec('should match child selector', async () => { | ||
expect('div > p').toMatch(new RegExp(CHILD_REGEX)); | ||
}); | ||
|
||
spec('should match attribute sibling selector', async () => { | ||
expect('[attribute] + p').toMatch(new RegExp(ATTRIBUTE_SIBLING_REGEX)); | ||
}); | ||
|
||
spec('should match attribute child selector', async () => { | ||
expect('[attribute] > p').toMatch(new RegExp(ATTRIBUTE_CHILD_REGEX)); | ||
}); | ||
|
||
spec('should match class sibling selector', async () => { | ||
expect('.class + p').toMatch(new RegExp(CLASS_SIBLING_REGEX)); | ||
}); | ||
|
||
spec('should match class child selector', async () => { | ||
expect('.class > p').toMatch(new RegExp(CLASS_CHILD_REGEX)); | ||
}); | ||
|
||
spec('should match nested attribute sibling selector', async () => { | ||
expect('&[attribute] + p').toMatch(new RegExp(NESTED_ATTRIBUTE_SIBLING_REGEX)); | ||
}); | ||
|
||
spec('should match nested attribute child selector', async () => { | ||
expect('&[attribute] > p').toMatch(new RegExp(NESTED_ATTRIBUTE_CHILD_REGEX)); | ||
}); | ||
|
||
spec('should match nested class sibling selector', async () => { | ||
expect('&.class + p').toMatch(new RegExp(NESTED_CLASS_SIBLING_REGEX)); | ||
}); | ||
|
||
spec('should match nested class child selector', async () => { | ||
expect('&.class > p').toMatch(new RegExp(NESTED_CLASS_CHILD_REGEX)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.