Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cli): stop spinner without error #5551

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cli/spinner_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,63 +79,63 @@ Deno.test("Spinner constructor accepts each color", async () => {
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_black.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[30m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[30m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_red.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[31m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[31m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_green.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[32m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[32m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_yellow.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[33m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[33m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_blue.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[34m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[34m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_magenta.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[35m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[35m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_cyan.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[36m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[36m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_white.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[37m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[37m⠋${COLOR_RESET} `);
}

{
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_color_gray.ts",
]);
assertEquals(text, `${LINE_CLEAR}\u001b[90m⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}\u001b[90m⠋${COLOR_RESET} `);
}
});

Expand Down Expand Up @@ -179,7 +179,7 @@ Deno.test("Spinner.color can get each color", () => {

Deno.test("Spinner.start() begins the sequence", async () => {
const text = await spawnDeno(["cli/testdata/spinner_cases/start.ts"]);
assertEquals(text, `${LINE_CLEAR}⠋${COLOR_RESET} `);
assertStringIncludes(text, `${LINE_CLEAR}⠋${COLOR_RESET} `);
});

Deno.test("Spinner.stop() terminates the sequence", async () => {
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/change_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spinner.start();
setTimeout(() => (spinner.message = "One dino 🦕"), 125); // 150
setTimeout(() => (spinner.message = "Two dinos 🦕🦕"), 200); // 225

setTimeout(spinner.stop, 500);
setTimeout(() => spinner.stop(), 500);
iuioiua marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_black.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "black" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_blue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "blue" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_cyan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "cyan" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_gray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "gray" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_green.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "green" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_magenta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "magenta" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_red.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "red" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_white.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "white" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_color_yellow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ color: "yellow" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_interval_10.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ interval: 10 });

spinner.start();

setTimeout(spinner.stop, 1000);
setTimeout(() => spinner.stop(), 1000);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_interval_750.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ interval: 750 });

spinner.start();

setTimeout(spinner.stop, 1000);
setTimeout(() => spinner.stop(), 1000);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner({ message: "Spinning with Deno 🦕" });

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/custom_spinner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const spinner = new Spinner({

spinner.start();

setTimeout(spinner.stop, 1000);
setTimeout(() => spinner.stop(), 1000);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/set_color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ spinner.start();
spinner.color = "black";
setTimeout(() => spinner.color = "red", 125); // 150

setTimeout(spinner.stop, 350);
setTimeout(() => spinner.stop(), 350);
2 changes: 1 addition & 1 deletion cli/testdata/spinner_cases/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const spinner = new Spinner();

spinner.start();

setTimeout(spinner.stop, 100);
setTimeout(() => spinner.stop(), 100);