Skip to content

Commit ca3df61

Browse files
committed
feat(regex): EXT_TS_REGEX
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent fb00cbe commit ca3df61

File tree

5 files changed

+405
-0
lines changed

5 files changed

+405
-0
lines changed

src/regex/__snapshots__/ts.snap

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
// Vitest Snapshot v1
2+
3+
exports[`unit:EXT_TS_REGEX > .cts > should match extension ".cts" 1`] = `
4+
{
5+
"0": ".cts",
6+
"1": undefined,
7+
"2": "c",
8+
"groups": {
9+
"dts": undefined,
10+
"type": "c",
11+
},
12+
}
13+
`;
14+
15+
exports[`unit:EXT_TS_REGEX > .cts > should match module id given last extension is ".cts" 1`] = `
16+
{
17+
"0": ".cts",
18+
"1": undefined,
19+
"2": "c",
20+
"groups": {
21+
"dts": undefined,
22+
"type": "c",
23+
},
24+
}
25+
`;
26+
27+
exports[`unit:EXT_TS_REGEX > .cts > should match module id given only extension is ".cts" 1`] = `
28+
{
29+
"0": ".cts",
30+
"1": undefined,
31+
"2": "c",
32+
"groups": {
33+
"dts": undefined,
34+
"type": "c",
35+
},
36+
}
37+
`;
38+
39+
exports[`unit:EXT_TS_REGEX > .mts > should match extension ".mts" 1`] = `
40+
{
41+
"0": ".mts",
42+
"1": undefined,
43+
"2": "m",
44+
"groups": {
45+
"dts": undefined,
46+
"type": "m",
47+
},
48+
}
49+
`;
50+
51+
exports[`unit:EXT_TS_REGEX > .mts > should match module id given last extension is ".mts" 1`] = `
52+
{
53+
"0": ".mts",
54+
"1": undefined,
55+
"2": "m",
56+
"groups": {
57+
"dts": undefined,
58+
"type": "m",
59+
},
60+
}
61+
`;
62+
63+
exports[`unit:EXT_TS_REGEX > .mts > should match module id given only extension is ".mts" 1`] = `
64+
{
65+
"0": ".mts",
66+
"1": undefined,
67+
"2": "m",
68+
"groups": {
69+
"dts": undefined,
70+
"type": "m",
71+
},
72+
}
73+
`;
74+
75+
exports[`unit:EXT_TS_REGEX > .ts > should match extension ".ts" 1`] = `
76+
{
77+
"0": ".ts",
78+
"1": undefined,
79+
"2": undefined,
80+
"groups": {
81+
"dts": undefined,
82+
"type": undefined,
83+
},
84+
}
85+
`;
86+
87+
exports[`unit:EXT_TS_REGEX > .ts > should match module id given last extension is ".ts" 1`] = `
88+
{
89+
"0": ".ts",
90+
"1": undefined,
91+
"2": undefined,
92+
"groups": {
93+
"dts": undefined,
94+
"type": undefined,
95+
},
96+
}
97+
`;
98+
99+
exports[`unit:EXT_TS_REGEX > .ts > should match module id given only extension is ".ts" 1`] = `
100+
{
101+
"0": ".ts",
102+
"1": undefined,
103+
"2": undefined,
104+
"groups": {
105+
"dts": undefined,
106+
"type": undefined,
107+
},
108+
}
109+
`;
110+
111+
exports[`unit:EXT_TS_REGEX > .tsx > should match extension ".tsx" 1`] = `
112+
{
113+
"0": ".tsx",
114+
"1": undefined,
115+
"2": undefined,
116+
"groups": {
117+
"dts": undefined,
118+
"type": undefined,
119+
},
120+
}
121+
`;
122+
123+
exports[`unit:EXT_TS_REGEX > .tsx > should match module id given last extension is ".tsx" 1`] = `
124+
{
125+
"0": ".tsx",
126+
"1": undefined,
127+
"2": undefined,
128+
"groups": {
129+
"dts": undefined,
130+
"type": undefined,
131+
},
132+
}
133+
`;
134+
135+
exports[`unit:EXT_TS_REGEX > .tsx > should match module id given only extension is ".tsx" 1`] = `
136+
{
137+
"0": ".tsx",
138+
"1": undefined,
139+
"2": undefined,
140+
"groups": {
141+
"dts": undefined,
142+
"type": undefined,
143+
},
144+
}
145+
`;
146+
147+
exports[`unit:EXT_TS_REGEX > dts > .d.cts > should match extension ".d.cts" 1`] = `
148+
{
149+
"0": ".d.cts",
150+
"1": "d",
151+
"2": "c",
152+
"groups": {
153+
"dts": "d",
154+
"type": "c",
155+
},
156+
}
157+
`;
158+
159+
exports[`unit:EXT_TS_REGEX > dts > .d.cts > should match module id given last extension is ".d.cts" 1`] = `
160+
{
161+
"0": ".d.cts",
162+
"1": "d",
163+
"2": "c",
164+
"groups": {
165+
"dts": "d",
166+
"type": "c",
167+
},
168+
}
169+
`;
170+
171+
exports[`unit:EXT_TS_REGEX > dts > .d.cts > should match module id given only extension is ".d.cts" 1`] = `
172+
{
173+
"0": ".d.cts",
174+
"1": "d",
175+
"2": "c",
176+
"groups": {
177+
"dts": "d",
178+
"type": "c",
179+
},
180+
}
181+
`;
182+
183+
exports[`unit:EXT_TS_REGEX > dts > .d.mts > should match extension ".d.mts" 1`] = `
184+
{
185+
"0": ".d.mts",
186+
"1": "d",
187+
"2": "m",
188+
"groups": {
189+
"dts": "d",
190+
"type": "m",
191+
},
192+
}
193+
`;
194+
195+
exports[`unit:EXT_TS_REGEX > dts > .d.mts > should match module id given last extension is ".d.mts" 1`] = `
196+
{
197+
"0": ".d.mts",
198+
"1": "d",
199+
"2": "m",
200+
"groups": {
201+
"dts": "d",
202+
"type": "m",
203+
},
204+
}
205+
`;
206+
207+
exports[`unit:EXT_TS_REGEX > dts > .d.mts > should match module id given only extension is ".d.mts" 1`] = `
208+
{
209+
"0": ".d.mts",
210+
"1": "d",
211+
"2": "m",
212+
"groups": {
213+
"dts": "d",
214+
"type": "m",
215+
},
216+
}
217+
`;
218+
219+
exports[`unit:EXT_TS_REGEX > dts > .d.ts > should match extension ".d.ts" 1`] = `
220+
{
221+
"0": ".d.ts",
222+
"1": "d",
223+
"2": undefined,
224+
"groups": {
225+
"dts": "d",
226+
"type": undefined,
227+
},
228+
}
229+
`;
230+
231+
exports[`unit:EXT_TS_REGEX > dts > .d.ts > should match module id given last extension is ".d.ts" 1`] = `
232+
{
233+
"0": ".d.ts",
234+
"1": "d",
235+
"2": undefined,
236+
"groups": {
237+
"dts": "d",
238+
"type": undefined,
239+
},
240+
}
241+
`;
242+
243+
exports[`unit:EXT_TS_REGEX > dts > .d.ts > should match module id given only extension is ".d.ts" 1`] = `
244+
{
245+
"0": ".d.ts",
246+
"1": "d",
247+
"2": undefined,
248+
"groups": {
249+
"dts": "d",
250+
"type": undefined,
251+
},
252+
}
253+
`;

src/regex/__tests__/ts.spec-d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @file Type Tests - EXT_TS_REGEX
3+
* @module ext-regex/regex/tests/unit-d/ts
4+
*/
5+
6+
import type TEST_SUBJECT from '../ts'
7+
8+
describe('unit-d:EXT_TS_REGEX', () => {
9+
it('should be instance of RegExp', () => {
10+
expectTypeOf<typeof TEST_SUBJECT>().toEqualTypeOf<RegExp>()
11+
})
12+
})

src/regex/__tests__/ts.spec.ts

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/**
2+
* @file Unit Tests - EXT_TS_REGEX
3+
* @module ext-regex/regex/tests/unit/ts
4+
*/
5+
6+
import TEST_SUBJECT from '../ts'
7+
8+
describe('unit:EXT_TS_REGEX', () => {
9+
describe('.cts', () => {
10+
it('should match extension ".cts"', () => {
11+
expect(TEST_SUBJECT.exec('.cts')).toMatchSnapshot()
12+
})
13+
14+
it('should match module id given last extension is ".cts"', () => {
15+
expect(TEST_SUBJECT.exec('build.config.cts')).toMatchSnapshot()
16+
})
17+
18+
it('should match module id given only extension is ".cts"', () => {
19+
expect(TEST_SUBJECT.exec('src/index.cts')).toMatchSnapshot()
20+
})
21+
})
22+
23+
describe('.mts', () => {
24+
it('should match extension ".mts"', () => {
25+
expect(TEST_SUBJECT.exec('.mts')).toMatchSnapshot()
26+
})
27+
28+
it('should match module id given last extension is ".mts"', () => {
29+
expect(TEST_SUBJECT.exec('build.config.mts')).toMatchSnapshot()
30+
})
31+
32+
it('should match module id given only extension is ".mts"', () => {
33+
expect(TEST_SUBJECT.exec('src/index.mts')).toMatchSnapshot()
34+
})
35+
})
36+
37+
describe('.ts', () => {
38+
it('should match extension ".ts"', () => {
39+
expect(TEST_SUBJECT.exec('.ts')).toMatchSnapshot()
40+
})
41+
42+
it('should match module id given last extension is ".ts"', () => {
43+
expect(TEST_SUBJECT.exec('build.config.ts')).toMatchSnapshot()
44+
})
45+
46+
it('should match module id given only extension is ".ts"', () => {
47+
expect(TEST_SUBJECT.exec('src/index.ts')).toMatchSnapshot()
48+
})
49+
})
50+
51+
describe('.tsx', () => {
52+
it('should match extension ".tsx"', () => {
53+
expect(TEST_SUBJECT.exec('.tsx')).toMatchSnapshot()
54+
})
55+
56+
it('should match module id given last extension is ".tsx"', () => {
57+
expect(TEST_SUBJECT.exec('Button.styles.tsx')).toMatchSnapshot()
58+
})
59+
60+
it('should match module id given only extension is ".tsx"', () => {
61+
expect(TEST_SUBJECT.exec('Button.tsx')).toMatchSnapshot()
62+
})
63+
})
64+
65+
describe('dts', () => {
66+
describe('.d.cts', () => {
67+
it('should match extension ".d.cts"', () => {
68+
expect(TEST_SUBJECT.exec('.d.cts')).toMatchSnapshot()
69+
})
70+
71+
it('should match module id given last extension is ".d.cts"', () => {
72+
expect(TEST_SUBJECT.exec('build.config.d.cts')).toMatchSnapshot()
73+
})
74+
75+
it('should match module id given only extension is ".d.cts"', () => {
76+
expect(TEST_SUBJECT.exec('dist/index.d.cts')).toMatchSnapshot()
77+
})
78+
})
79+
80+
describe('.d.mts', () => {
81+
it('should match extension ".d.mts"', () => {
82+
expect(TEST_SUBJECT.exec('.d.mts')).toMatchSnapshot()
83+
})
84+
85+
it('should match module id given last extension is ".d.mts"', () => {
86+
expect(TEST_SUBJECT.exec('build.config.d.mts')).toMatchSnapshot()
87+
})
88+
89+
it('should match module id given only extension is ".d.mts"', () => {
90+
expect(TEST_SUBJECT.exec('dist/index.d.mts')).toMatchSnapshot()
91+
})
92+
})
93+
94+
describe('.d.ts', () => {
95+
it('should match extension ".d.ts"', () => {
96+
expect(TEST_SUBJECT.exec('.d.ts')).toMatchSnapshot()
97+
})
98+
99+
it('should match module id given last extension is ".d.ts"', () => {
100+
expect(TEST_SUBJECT.exec('build.config.d.ts')).toMatchSnapshot()
101+
})
102+
103+
it('should match module id given only extension is ".d.ts"', () => {
104+
expect(TEST_SUBJECT.exec('dist/index.d.ts')).toMatchSnapshot()
105+
})
106+
})
107+
})
108+
})

src/regex/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
*/
55

66
export { default as EXT_DTS_REGEX } from './dts'
7+
export { default as EXT_TS_REGEX } from './ts'

0 commit comments

Comments
 (0)