Skip to content

Commit bf1c25a

Browse files
Dev update.
1 parent 7ce4d41 commit bf1c25a

File tree

3 files changed

+53
-12
lines changed

3 files changed

+53
-12
lines changed

tests/Regex.test.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,33 @@ describe('Regex', () => {
3939
let m = regex.match(str);
4040
expect(m.value).equal('ABCDE');
4141
expect(m.index).equal(0);
42-
expect(m.namedGroups.first.value).equal('ABCDE');
42+
const firstGroup = m.namedGroups.first;
43+
expect(firstGroup).toBeDefined();
44+
expect(firstGroup?.value).equal('ABCDE');
4345

4446
m = regex.match(str, 20);
4547
expect(m.value).equal('abcde');
4648
expect(m.index).equal(26);
47-
expect(m.namedGroups.first.value).equal('abcde');
49+
const firstGroupSecond = m.namedGroups.first;
50+
expect(firstGroupSecond).toBeDefined();
51+
expect(firstGroupSecond?.value).equal('abcde');
4852
});
4953
});
5054

5155
describe('.matches(input)', () => {
5256
it('should capture all instances', () => {
53-
function check (m: readonly Match[]): void
54-
{
55-
expect(m.length).equal(2);
56-
expect(m[0].value).equal('ABCDE');
57-
expect(m[0].index).equal(0);
58-
expect(m[1].value).equal('abcde');
59-
expect(m[1].index).equal(26);
60-
}
61-
62-
check(regex.matches(str));
57+
function check (m: readonly Match[]): void
58+
{
59+
expect(m.length).equal(2);
60+
const firstMatch = m[0];
61+
const secondMatch = m[1];
62+
expect(firstMatch).toBeDefined();
63+
expect(secondMatch).toBeDefined();
64+
expect(firstMatch?.value).equal('ABCDE');
65+
expect(firstMatch?.index).equal(0);
66+
expect(secondMatch?.value).equal('abcde');
67+
expect(secondMatch?.index).equal(26);
68+
} check(regex.matches(str));
6369
check(regex4.matches(str));
6470
});
6571
});

tests/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"skipLibCheck": true,
6+
"types": ["vitest/globals", "node"]
7+
},
8+
"include": [
9+
"**/*.ts",
10+
"**/*.js"
11+
],
12+
"exclude": []
13+
}

vitest.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
globals: true,
6+
environment: 'node',
7+
coverage: {
8+
enabled: true,
9+
reporter: ['text'],
10+
include: ['src/**/*.ts'],
11+
exclude: ['src/**/*.d.ts'],
12+
thresholds: {
13+
global: {
14+
branches: 80,
15+
functions: 80,
16+
lines: 80,
17+
statements: 80
18+
}
19+
}
20+
},
21+
},
22+
});

0 commit comments

Comments
 (0)