Spaces:
Running
Running
File size: 1,127 Bytes
2f49513 |
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 40 41 42 43 |
import { render, screen } from "@testing-library/react";
import BotFace from "../BotFace";
describe("BotFace", () => {
const mockAnalyser = {
getFloatFrequencyData: jest.fn((array) => {
array[10] = -100;
}),
};
const mockAudioContext = {
createAnalyser: jest.fn(() => mockAnalyser),
};
const mockAudioNode = {
context: mockAudioContext,
connect: jest.fn(),
} as unknown as AudioNode;
test("renders loading state when connecting", () => {
render(
<BotFace audioSource={mockAudioNode} connectionStatus="connecting" />
);
expect(screen.getByTestId("loading-indicator")).toBeInTheDocument();
});
test("renders disconnected icon when disconnected", () => {
render(
<BotFace audioSource={mockAudioNode} connectionStatus="disconnected" />
);
expect(
screen.getByTitle("Enable microphone to connect")
).toBeInTheDocument();
});
test("renders emoji when connected", () => {
render(
<BotFace audioSource={mockAudioNode} connectionStatus="connected" />
);
expect(screen.getByText("🙂")).toBeInTheDocument();
});
});
|