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): improve spinner test coverage #5047

Merged
merged 1 commit into from
Jun 17, 2024
Merged
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
9 changes: 9 additions & 0 deletions cli/spinner_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
assertLess,
assertStringIncludes,
} from "@std/assert";
import { delay } from "@std/async/delay";
import { Spinner } from "./spinner.ts";

async function spawnDeno(args: string[], opts?: Deno.CommandOptions) {
Expand All @@ -27,6 +28,14 @@ const COLOR_RESET = "\u001b[0m";
const LINE_CLEAR = "\r\u001b[K";
const decoder = new TextDecoder();

Deno.test("Spinner can start and stop", async () => {
const spinner = new Spinner({ message: "Loading..." });
spinner.start();
spinner.start(); // This doesn't throw, but ignored
await delay(300);
spinner.stop();
});

Deno.test("Spinner constructor accepts spinner", async () => {
const text = await spawnDeno([
"cli/testdata/spinner_cases/custom_spinner.ts",
Expand Down