Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
metonym committed Nov 10, 2024
1 parent e3abba7 commit 176aac3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions tests/Writer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
});
});
2 changes: 1 addition & 1 deletion tests/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ export type GenericsMultipleProps<Row, Header> = {
export default class GenericsMultiple<
Row extends DataTableRow = DataTableRow,
Header extends DataTableRow = DataTableRow
Header extends DataTableRow = DataTableRow,
> extends SvelteComponentTyped<
GenericsMultipleProps<Row, Header>,
Record<string, any>,
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/carbon/types/DataTable/DataTable.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export type DataTableProps<Row> = Omit<$RestProps, keyof $Props<Row>> &
$Props<Row>;

export default class DataTable<
Row extends DataTableRow = DataTableRow
Row extends DataTableRow = DataTableRow,
> extends SvelteComponentTyped<
DataTableProps<Row>,
{
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/glob/types/button/Button.svelte.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/generics-multiple/output.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type GenericsMultipleProps<Row, Header> = {

export default class GenericsMultiple<
Row extends DataTableRow = DataTableRow,
Header extends DataTableRow = DataTableRow
Header extends DataTableRow = DataTableRow,
> extends SvelteComponentTyped<
GenericsMultipleProps<Row, Header>,
Record<string, any>,
Expand Down

0 comments on commit 176aac3

Please sign in to comment.