Files
Boshen 523a30a016 style(all): apply oxfmt default options (#16091)
Embrace the defaults!

---------

Co-authored-by: Yuji Sugiura <y.sugiura.0316@gmail.com>
2025-11-25 15:56:24 +09:00

53 lines
1.3 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { isolatedDeclaration, isolatedDeclarationSync } from "../index";
describe("isolated declaration", () => {
const code = `
/**
* jsdoc 1
*/
export class A {
/**
* jsdoc 2
*/
foo = "bar";
}
// Do not keep normal comments
export class B {}
`;
it("matches output", () => {
const ret = isolatedDeclarationSync("test.ts", code, { sourcemap: true });
expect(ret).toMatchObject({
code:
"/**\n" +
"* jsdoc 1\n" +
"*/\n" +
"export declare class A {\n" +
"\t/**\n" +
"\t* jsdoc 2\n" +
"\t*/\n" +
"\tfoo: string;\n" +
"}\n" +
"export declare class B {}\n",
map: {
names: [],
sources: ["test.ts"],
sourcesContent: [code],
version: 3,
},
errors: [],
});
});
it("produces same result as sync", async () => {
const syncResult = isolatedDeclarationSync("test.ts", code, { sourcemap: true });
const asyncResult = await isolatedDeclaration("test.ts", code, { sourcemap: true });
expect(asyncResult.code).toEqual(syncResult.code);
expect(asyncResult.errors.length).toBe(syncResult.errors.length);
expect(asyncResult.map).toMatchObject(syncResult.map!);
});
});