From 176aac3bffdcc534fe25b8d60f288df7c6b18052 Mon Sep 17 00:00:00 2001 From: metonym Date: Thu, 12 Sep 2024 13:10:42 -0700 Subject: [PATCH] test: update tests --- tests/Writer.test.ts | 18 +++++++++--------- tests/__snapshots__/fixtures.test.ts.snap | 2 +- .../types/DataTable/DataTable.svelte.d.ts | 2 +- tests/e2e/glob/types/button/Button.svelte.d.ts | 2 +- tests/fixtures.test.ts | 2 +- tests/fixtures/generics-multiple/output.d.ts | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/Writer.test.ts b/tests/Writer.test.ts index da8b039..a2f5fc9 100644 --- a/tests/Writer.test.ts +++ b/tests/Writer.test.ts @@ -6,33 +6,33 @@ describe("Writer", () => { global.console.error = jest.fn(); }); - test("TypeScript", () => { + test("TypeScript", async () => { const consoleError = jest.spyOn(console, "error"); const writer = new Writer({ parser: "typescript", printWidth: 120 }); - expect(writer.format("interface I {a:boolean}")).toEqual("interface I {\n a: boolean;\n}\n"); + expect(await writer.format("interface I {a:boolean}")).toEqual("interface I {\n a: boolean;\n}\n"); expect(consoleError).toHaveBeenCalledTimes(0); // Invalid JSON should emit Prettier parsing error - expect(writer.format("a:boolean}")).toEqual("a:boolean}"); + expect(await writer.format("a:boolean}")).toEqual("a:boolean}"); expect(consoleError).toHaveBeenCalledTimes(1); }); - test("JSON", () => { + test("JSON", async () => { const consoleError = jest.spyOn(console, "error"); const writer = new Writer({ parser: "json", printWidth: 80 }); - expect(writer.format("{a:null}")).toEqual('{ "a": null }\n'); + expect(await writer.format("{a:null}")).toEqual('{ "a": null }\n'); expect(consoleError).toHaveBeenCalledTimes(0); // Invalid JSON should emit Prettier parsing error - expect(writer.format("a:null")).toEqual("a:null"); + expect(await writer.format("a:null")).toEqual("a:null"); expect(consoleError).toHaveBeenCalledTimes(1); }); - test("Markdown", () => { + test("Markdown", async () => { const writer = new Writer({ parser: "markdown", printWidth: 80 }); - expect(writer.format("## text")).toEqual("## text\n"); - expect(writer.format({ a: null })).toEqual({ a: null }); + expect(await writer.format("## text")).toEqual("## text\n"); + expect(await writer.format({ a: null })).toEqual({ a: null }); }); }); diff --git a/tests/__snapshots__/fixtures.test.ts.snap b/tests/__snapshots__/fixtures.test.ts.snap index 83a721d..217ad93 100644 --- a/tests/__snapshots__/fixtures.test.ts.snap +++ b/tests/__snapshots__/fixtures.test.ts.snap @@ -1385,7 +1385,7 @@ export type GenericsMultipleProps = { export default class GenericsMultiple< Row extends DataTableRow = DataTableRow, - Header extends DataTableRow = DataTableRow + Header extends DataTableRow = DataTableRow, > extends SvelteComponentTyped< GenericsMultipleProps, Record, diff --git a/tests/e2e/carbon/types/DataTable/DataTable.svelte.d.ts b/tests/e2e/carbon/types/DataTable/DataTable.svelte.d.ts index f3c9331..cbfcc4a 100644 --- a/tests/e2e/carbon/types/DataTable/DataTable.svelte.d.ts +++ b/tests/e2e/carbon/types/DataTable/DataTable.svelte.d.ts @@ -187,7 +187,7 @@ export type DataTableProps = Omit<$RestProps, keyof $Props> & $Props; export default class DataTable< - Row extends DataTableRow = DataTableRow + Row extends DataTableRow = DataTableRow, > extends SvelteComponentTyped< DataTableProps, { diff --git a/tests/e2e/glob/types/button/Button.svelte.d.ts b/tests/e2e/glob/types/button/Button.svelte.d.ts index cdea96c..1c0e76e 100644 --- a/tests/e2e/glob/types/button/Button.svelte.d.ts +++ b/tests/e2e/glob/types/button/Button.svelte.d.ts @@ -9,7 +9,7 @@ export declare function computeTreeLeafDepth(): any; * Finds the nearest parent tree node */ export declare function findParentTreeNode( - node: HTMLElement + node: HTMLElement, ): null | HTMLElement; type $RestProps = SvelteHTMLElements["button"]; diff --git a/tests/fixtures.test.ts b/tests/fixtures.test.ts index 86c06fa..6854812 100644 --- a/tests/fixtures.test.ts +++ b/tests/fixtures.test.ts @@ -54,7 +54,7 @@ describe("fixtures (TypeScript)", async () => { filePath, source: fixtures_map.get(filePath)!, }); - const api_ts = writer.format(writeTsDefinition({ ...metadata, ...parsed_component })); + const api_ts = await writer.format(writeTsDefinition({ ...metadata, ...parsed_component })); // Snapshot the output; if the test fails, output has changed. expect(api_ts).toMatchSnapshot(); diff --git a/tests/fixtures/generics-multiple/output.d.ts b/tests/fixtures/generics-multiple/output.d.ts index 9f2e49b..9a489bd 100644 --- a/tests/fixtures/generics-multiple/output.d.ts +++ b/tests/fixtures/generics-multiple/output.d.ts @@ -26,7 +26,7 @@ export type GenericsMultipleProps = { export default class GenericsMultiple< Row extends DataTableRow = DataTableRow, - Header extends DataTableRow = DataTableRow + Header extends DataTableRow = DataTableRow, > extends SvelteComponentTyped< GenericsMultipleProps, Record,