fix(napi/transform): fix test

This commit is contained in:
Boshen 2024-09-03 11:03:44 +08:00
parent 59abf27d95
commit ea7a52f1b4
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1
2 changed files with 7 additions and 7 deletions

View file

@ -234,7 +234,7 @@ export interface TypeScriptBindingOptions {
* Rewrite or remove TypeScript import/export declaration extensions.
*
* - When set to `rewrite`, it will change `.ts`, `.mts`, `.cts` extensions to `.js`, `.mjs`, `.cjs` respectively.
* - When set to `remove`, it will remove the extensions entirely.
* - When set to `remove`, it will remove `.ts`/`.mts`/`.cts`/`.tsx` extension entirely.
* - When set to `true`, it's equivalent to `rewrite`.
* - When set to `false` or omitted, no changes will be made to the extensions.
*

View file

@ -4,8 +4,8 @@ import assert from "assert";
console.log(`Testing on ${process.platform}-${process.arch}`);
test(oxc.isolatedDeclaration("test.ts", "class A {}", { sourcemap: true }), {
sourceText: "declare class A {}\n",
sourceMap: {
code: "declare class A {}\n",
map: {
mappings: "AAAA,cAAM,EAAE,CAAE",
names: [],
sources: ["test.ts"],
@ -14,12 +14,12 @@ test(oxc.isolatedDeclaration("test.ts", "class A {}", { sourcemap: true }), {
});
function test(ret, expected) {
console.log(ret.sourceText);
console.log(ret.sourceMap);
console.log(ret.code);
console.log(ret.map);
for (const error of ret.errors) {
console.log(error);
}
assert.equal(ret.sourceText, expected.sourceText);
assert.deepEqual(ret.sourceMap, expected.sourceMap);
assert.equal(ret.code, expected.code);
assert.deepEqual(ret.map, expected.map);
assert(ret.errors.length == 0);
}