Skip to content

Commit 4fb7c50

Browse files
committed
chore: use vitest instead of jest
1 parent 7b7611b commit 4fb7c50

24 files changed

+2232
-4166
lines changed
+10-14
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
import { generateSource, Parser } from '../utils'
1+
import { describe, it, expect } from 'vitest';
2+
import { generateSource, Parser } from '../utils';
23

34
function parseExpressionAt(input: string, pos: number) {
45
return Parser.parseExpressionAt(input, pos, {
56
sourceType: 'module',
67
ecmaVersion: 'latest',
7-
locations: true
8-
})
8+
locations: true,
9+
});
910
}
1011

11-
describe('parseExpressionAt API', function() {
12-
it('normal', function() {
13-
const node = parseExpressionAt(generateSource([
14-
`<tag prop={`,
15-
` (): void => {}`,
16-
`} />`
17-
]), 14)
18-
19-
expect(node.type).toEqual('ArrowFunctionExpression')
20-
})
21-
})
12+
describe('parseExpressionAt API', function () {
13+
it('normal', function () {
14+
const node = parseExpressionAt(generateSource([`<tag prop={`, ` (): void => {}`, `} />`]), 14);
2215

16+
expect(node.type).toEqual('ArrowFunctionExpression');
17+
});
18+
});

__test__/arrow-function/type.test.ts

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
import { equalNode, generateSource, parseSource } from '../utils'
2-
import ArrowFunctionTypeSnapshot from '../__snapshot__/arrow-function/type'
1+
import { describe, it } from 'vitest';
2+
import { equalNode, generateSource, parseSource } from '../utils';
3+
import ArrowFunctionTypeSnapshot from '../__snapshot__/arrow-function/type';
34

45
const issue38File = `
56
let defaultHashSize = 0
67
export const getHashPlaceholderGenerator = (): any => {
78
let nextIndex = 0;
89
return (optionName: string, hashSize: number = defaultHashSize) => {}
910
}
10-
`
11+
`;
1112

12-
const issue39File = `export const getPureFunctions = ({ treeshake }: NormalizedInputOptions): PureFunctions => {};`
13+
const issue39File = `export const getPureFunctions = ({ treeshake }: NormalizedInputOptions): PureFunctions => {};`;
1314

1415
describe('arrow-function type test', () => {
1516
it('assignment pattern', () => {
16-
const node = parseSource(generateSource([
17-
`(x = 42): void => {}`
18-
]))
17+
const node = parseSource(generateSource([`(x = 42): void => {}`]));
1918

20-
equalNode(node, ArrowFunctionTypeSnapshot.AssignmentPattern)
21-
})
19+
equalNode(node, ArrowFunctionTypeSnapshot.AssignmentPattern);
20+
});
2221

2322
it('issue 32', () => {
24-
const node = parseSource(generateSource([
25-
`const testApp = async(app: string, index: number) => {`,
26-
`};`
27-
]))
23+
const node = parseSource(
24+
generateSource([`const testApp = async(app: string, index: number) => {`, `};`])
25+
);
2826

29-
equalNode(node, ArrowFunctionTypeSnapshot.Issue32)
30-
})
27+
equalNode(node, ArrowFunctionTypeSnapshot.Issue32);
28+
});
3129

3230
it('issue 38', () => {
33-
const node = parseSource(issue38File)
31+
const node = parseSource(issue38File);
3432

35-
equalNode(node, ArrowFunctionTypeSnapshot.Issue38)
36-
})
33+
equalNode(node, ArrowFunctionTypeSnapshot.Issue38);
34+
});
3735

3836
it('issue 39', () => {
39-
const node = parseSource(issue39File)
37+
const node = parseSource(issue39File);
4038

41-
equalNode(node, ArrowFunctionTypeSnapshot.Issue39)
42-
})
43-
})
39+
equalNode(node, ArrowFunctionTypeSnapshot.Issue39);
40+
});
41+
});

__test__/assert/index.test.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
import { equalNode, parseSource, parseSourceShouldThrowError } from '../utils'
2-
import AssertionSnapshot from '../__snapshot__/assert'
1+
import { describe, it, expect } from 'vitest';
2+
import { equalNode, parseSource, parseSourceShouldThrowError } from '../utils';
3+
import AssertionSnapshot from '../__snapshot__/assert';
34

45
describe('assert', () => {
56
it('import assert', () => {
6-
const node = parseSource(`import json from './foo.json' assert { type: 'json' };`)
7+
const node = parseSource(`import json from './foo.json' assert { type: 'json' };`);
78

8-
equalNode(node, AssertionSnapshot.ImportAssert)
9-
})
9+
equalNode(node, AssertionSnapshot.ImportAssert);
10+
});
1011

1112
it('import with', () => {
12-
const node = parseSource(`import json from './foo.json' with { type: 'json' };`)
13+
const node = parseSource(`import json from './foo.json' with { type: 'json' };`);
1314

14-
equalNode(node, AssertionSnapshot.ImportWith)
15-
})
15+
equalNode(node, AssertionSnapshot.ImportWith);
16+
});
1617

1718
it('import with duplicate', () => {
1819
const res = parseSourceShouldThrowError(
1920
`import json from './foo.json' with { type: 'json', type: 'json' };`,
2021
'Duplicated key in attributes',
2122
'(1:63)'
22-
)
23+
);
2324

24-
expect(res).toBe(true)
25-
})
25+
expect(res).toBe(true);
26+
});
2627

2728
it('dynamic import assert', () => {
28-
const node = parseSource(`import("./foo.json", { with: { type: "json" } });`)
29+
const node = parseSource(`import("./foo.json", { with: { type: "json" } });`);
2930

30-
equalNode(node, AssertionSnapshot.DynamicImportAssert)
31-
})
31+
equalNode(node, AssertionSnapshot.DynamicImportAssert);
32+
});
3233

3334
it('export all as assert', () => {
34-
const node = parseSource(`export * as name from "./foo.json" with { type: "json" };`)
35+
const node = parseSource(`export * as name from "./foo.json" with { type: "json" };`);
3536

36-
equalNode(node, AssertionSnapshot.ExportAllAsAssert)
37-
})
38-
})
37+
equalNode(node, AssertionSnapshot.ExportAllAsAssert);
38+
});
39+
});

0 commit comments

Comments
 (0)