test(napi/transform): add test for not default es transform

This commit is contained in:
Boshen 2024-11-10 00:21:26 +08:00
parent eea4ab830a
commit be819dded1
No known key found for this signature in database
GPG key ID: 67715A371E534061

View file

@ -2,7 +2,7 @@ import { assert, describe, it } from 'vitest';
import oxc from './index';
describe('transform', () => {
describe('simple', () => {
const code = 'export class A<T> {}';
it('matches output', () => {
@ -31,6 +31,25 @@ describe('transform', () => {
});
});
describe('transform', () => {
it('should not transform by default', () => {
const cases = [
'() => {};',
'a ** b;',
'async function foo() {}',
'({ ...x });',
'try {} catch {}',
'a ?? b;',
'a ||= b;',
'class foo {\n\tstatic {}\n}',
];
for (const code of cases) {
const ret = oxc.transform('test.ts', code);
assert.equal(ret.code.trim(), code);
}
});
});
describe('modules', () => {
it('should transform export = and import ', () => {
const code = `