nandi/oripublic Fork 0
3017563d783a895a85f8f8ad162b58bb5d944946
Commits
Clone
git clone https://git.rickub.com/nandi/ori.git
git clone ssh://git@rickub.com/nandi/ori.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

forked from bots-garden/ori

WorkingIndicator.test.tsx · 39 lines · 1.1 KBTypeScript Blame HistoryRaw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { act, render, screen } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
	phraseIntervalMs,
	WorkingIndicator,
	workingPhrases,
} from "./WorkingIndicator";

describe("WorkingIndicator", () => {
	beforeEach(() => {
		vi.useFakeTimers();
	});

	afterEach(() => {
		vi.useRealTimers();
	});

	it("shows the first working phrase with a spinner", () => {
		const { container } = render(<WorkingIndicator />);
		expect(screen.getByText(workingPhrases[0])).toBeDefined();
		expect(container.querySelector(".spinner")).not.toBeNull();
	});

	it("rotates to the next phrase after the interval", () => {
		render(<WorkingIndicator />);
		act(() => {
			vi.advanceTimersByTime(phraseIntervalMs);
		});
		expect(screen.getByText(workingPhrases[1])).toBeDefined();
	});

	it("wraps around to the first phrase after the full cycle", () => {
		render(<WorkingIndicator />);
		act(() => {
			vi.advanceTimersByTime(phraseIntervalMs * workingPhrases.length);
		});
		expect(screen.getByText(workingPhrases[0])).toBeDefined();
	});
});