Skip to content

Commit

Permalink
fix: updates tests after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
tvillaren committed Nov 4, 2024
1 parent 48619c0 commit 06d43d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/__snapshots__/cli.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports[`Config Prompt Tests Skip config prompt should have selected the right o
Execute "config" config (--config=config)
❯ Don't use the config ? You have multiple configs available in "ts-to-zod.config.js"
What do you want? Don't use the config
✔ Validating generated types
🎉 Zod schemas generated!
"
`;
18 changes: 9 additions & 9 deletions src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ describe("Oclif-provided Flags Tests", () => {
-i, --init Create a ts-to-zod.config.js file
-k, --keepComments Keep parameters comments
-v, --version Show CLI version.
-w, --watch Watch input file(s) for changes and re-run
related task
-w, --watch Watch input file(s) for changes and re-run related task
--inferredTypes=<value> Path of z.infer<> types file
--skipParseJSDoc Skip the creation of zod validators from JSDoc
annotations
--skipParseJSDoc Skip the creation of zod validators from JSDoc annotations
--skipValidation Skip the validation step (not recommended)
DESCRIPTION
Expand Down Expand Up @@ -76,19 +74,17 @@ describe("Config Prompt Tests", () => {
// Up Arrow key code \u001B[A + ENTER key code \n with a delay of 2000ms
setTimeout(() => stdin.send("\u001B[A\n"), 2000);

const { stdout, stderr } = await runCommand([
const { stdout } = await runCommand([
".",
basicInputPath,
basicOutputPath,
]);

expect(
replaceAngleBracket(normalizeLineEndings(stdout))
removeLoadingDots(replaceAngleBracket(normalizeLineEndings(stdout)))
).toMatchSnapshot();

// Ora spinner outputs to stderr by default, we
expect(stderr).toContain("- Validating generated types");
expect(stderr).toContain("✔ Validating generated types");
expect(stdout).toContain("✔ Validating generated types");

expect(readFileCrossEnv(basicOutputPath)).toEqual(
readFileCrossEnv(basicSnapshotPath)
Expand All @@ -110,6 +106,10 @@ function makePosixPath(str: string) {
return str.split(sep).join(posix.sep);
}

function removeLoadingDots(content: string) {
return content.replace(/(|||||||) Validating generated types/g, "");
}

function normalizeLineEndings(content: string) {
return content.replace(/\r\n/g, "\n"); // Replace Windows (\r\n) with Unix (\n)
}
Expand Down

0 comments on commit 06d43d9

Please sign in to comment.