Skip to content

Commit

Permalink
3 line test
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech committed Dec 30, 2024
1 parent cbeca04 commit d77c516
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions cli/prompt_secret_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,19 +561,31 @@ Deno.test("promptSecret() wraps characters wider than console columns", () => {
stub(Deno.stdin, "setRaw");
stub(Deno.stdin, "isTerminal", () => true);
stub(Deno, "consoleSize", () => {
return { columns: 32, rows: 20 };
return { columns: 5, rows: 20 };
});

const expectedOutput = [
"Please provide the password: ",
"? ",
"\r\x1b[K",
"Please provide the password: *",
"? *",
"\r\x1b[K",
"Please provide the password: **",
"? **",
"\r\x1b[K",
"Please provide the password: ***",
"? ***",
"\r\x1b[K",
"*",
"\r\x1b[K",
"**",
"\r\x1b[K",
"***",
"\r\x1b[K",
"****",
"\r\x1b[K",
"*****",
"\r\x1b[K",
"*",
"\r\x1b[K",
"**",
"\n",
];

Expand All @@ -596,6 +608,12 @@ Deno.test("promptSecret() wraps characters wider than console columns", () => {
"e",
"n",
"o",
" ",
"r",
"u",
"l",
"e",
"s",
"\r",
];

Expand All @@ -610,9 +628,9 @@ Deno.test("promptSecret() wraps characters wider than console columns", () => {
},
);

const password = promptSecret("Please provide the password:");
const password = promptSecret("?");

assertEquals(password, "deno");
assertEquals(password, "deno rules");
assertEquals(expectedOutput, actualOutput);
restore();
});

0 comments on commit d77c516

Please sign in to comment.