Skip to content

Commit

Permalink
fix: test syntax error
Browse files Browse the repository at this point in the history
  • Loading branch information
lublagg committed Nov 18, 2024
1 parent 6a80582 commit 8c5660d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/chat-transcript.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@ describe("test chat transcript component", () => {
const messages = within(transcript).getAllByTestId("chat-message");
expect(messages).toHaveLength(2);

// note: messages from AI should be assertive, while messages from user will not have aria-live
expect(messages[0]).toHaveAttribute("aria-live", "assertive");
expect(messages[1]).not.toHaveAttribute("aria-live");

messages.forEach((message: HTMLElement, index: number) => {
const labelContent = `${chatTranscript.messages[index].speaker} at ${chatTranscript.messages[index].timestamp}`;
const shouldBeLive = chatTranscript.messages[index].speaker === "DAVAI";

expect(message).toHaveAttribute("aria-label", labelContent);
if (shouldBeLive) {
expect(message).toHaveAttribute("aria-live", "assertive");
} else {
expect(message).not.toHaveAttribute("aria-live");
}

const speaker = within(message).getByTestId("chat-message-speaker");
expect(speaker).toBeInTheDocument();
Expand Down

0 comments on commit 8c5660d

Please sign in to comment.