From be819dded186fa4254e3cdaeb6a004b0f6fa3930 Mon Sep 17 00:00:00 2001 From: Boshen Date: Sun, 10 Nov 2024 00:21:26 +0800 Subject: [PATCH] test(napi/transform): add test for not default es transform --- napi/transform/test/transform.test.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/napi/transform/test/transform.test.ts b/napi/transform/test/transform.test.ts index faad8be0d9a2e..fa7aeaecd2909 100644 --- a/napi/transform/test/transform.test.ts +++ b/napi/transform/test/transform.test.ts @@ -2,7 +2,7 @@ import { assert, describe, it } from 'vitest'; import oxc from './index'; -describe('transform', () => { +describe('simple', () => { const code = 'export class A {}'; 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 = `