Skip to content

Commit eaff3d9

Browse files
committed
test(napi/parser): split tests for convertSpanUtf16 (oxc-project#9113)
Minor cleanup. I was smashing all assertions in a single `it`, but I've wanted to split them.
1 parent 0937a55 commit eaff3d9

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

napi/parser/test/parse.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,19 @@ describe('parse', () => {
9393
});
9494
});
9595

96-
it('utf16 span', async () => {
97-
const code = "'🤨'";
98-
{
99-
const ret = await parseAsync('test.js', code);
100-
expect(ret.program.end).toMatchInlineSnapshot(`6`);
101-
}
102-
{
103-
const ret = await parseAsync('test.js', code, {
96+
describe('UTF-16 span', () => {
97+
it('basic', async () => {
98+
const code = "'🤨'";
99+
const utf8 = await parseAsync('test.js', code);
100+
expect(utf8.program.end).toMatchInlineSnapshot(`6`);
101+
const utf16 = await parseAsync('test.js', code, {
104102
convertSpanUtf16: true,
105103
});
106-
expect(ret.program.end).toMatchInlineSnapshot(`4`);
107-
}
108-
{
109-
const code = `// ∞`;
110-
const ret = await parseAsync('test.js', code, {
104+
expect(utf16.program.end).toMatchInlineSnapshot(`4`);
105+
});
106+
107+
it('comment', async () => {
108+
const ret = await parseAsync('test.js', `// ∞`, {
111109
convertSpanUtf16: true,
112110
});
113111
expect(ret.comments).toMatchInlineSnapshot(`
@@ -120,8 +118,9 @@ it('utf16 span', async () => {
120118
},
121119
]
122120
`);
123-
}
124-
{
121+
});
122+
123+
it('module record', async () => {
125124
const ret = await parseAsync('test.js', `"🤨";import x from "x"; export { x };import("y");import.meta.z`, {
126125
convertSpanUtf16: true,
127126
});
@@ -204,8 +203,9 @@ it('utf16 span', async () => {
204203
],
205204
}
206205
`);
207-
}
208-
{
206+
});
207+
208+
it('error', async () => {
209209
const ret = await parseAsync('test.js', `"🤨";asdf asdf`, {
210210
convertSpanUtf16: true,
211211
});
@@ -224,7 +224,7 @@ it('utf16 span', async () => {
224224
},
225225
]
226226
`);
227-
}
227+
});
228228
});
229229

230230
describe('error', () => {

0 commit comments

Comments
 (0)