Skip to content

Commit

Permalink
Cleaning up tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjprescott committed Feb 5, 2025
1 parent 4d08a61 commit 8b78fcb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -542,19 +542,19 @@ describe("Typescript Type Transform", () => {
}
export function dogToApplication(item: any): Dog {
return {
"kind": item.kind
};
}
export function dogToTransport(item: Dog): any {
return {
"kind": item.kind
};
}
export function catToApplication(item: any): Cat {
return {
"kind": item.kind
};
}
Expand All @@ -568,22 +568,38 @@ describe("Typescript Type Transform", () => {
if(item.kind === "cat") {
return catToApplication(item as Cat)
}
if(item.kind === "dog") {
return dogToApplication(item as Dog)
}
throw new Error(\`Unexpected discriminated variant \${item.kind}\`);
}
export function petToTransport(item: Pet): any {
if(item.kind === "cat") {
return catToTransport(item as Cat)
}
if(item.kind === "dog") {
return dogToTransport(item as Dog)
}
throw new Error(\`Unexpected discriminated variant \${item.kind}\`);
}
`;
expect(actualContent).toBe(expectedContent);
`;

// workaround to ensure the the test passes regardless of leading whitespace
const lines = (actualContent as string).split("\n");
let transformed = "";
for (const line of lines) {
if (line.trimStart() === "") {
transformed += "\n";
} else {
transformed += `${line}\n`;
}
}
expect(transformed).toBe(expectedContent);
});
});
});
4 changes: 2 additions & 2 deletions packages/playground-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"test": "vitest run",
"test:watch": "vitest -w",
"watch": "vite",
"test:e2e": "cross-env NODE_ENV=production PW_EXPERIMENTAL_TS_ESM=1 playwright test -c e2e ",
"test:e2e:headed": "cross-env NODE_ENV=production PW_EXPERIMENTAL_TS_ESM=1 playwright test -c e2e --headed",
"test:e2e": "cross-env PW_EXPERIMENTAL_TS_ESM=1 playwright test -c e2e ",
"test:e2e:headed": "cross-env PW_EXPERIMENTAL_TS_ESM=1 playwright test -c e2e --headed",
"lint": "eslint . --max-warnings=0",
"lint:fix": "eslint . --fix"
},
Expand Down

0 comments on commit 8b78fcb

Please sign in to comment.