Skip to content

Commit

Permalink
fix: text syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lublagg committed Nov 19, 2024
1 parent 6e00cda commit 4b3bc21
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions src/components/readaloud-menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ describe("test read aloud menu component", () => {
const mockHandleToggle = jest.fn();
const mockHandleSelect = jest.fn();

beforeEach(() => {
mockHandleToggle.mockClear();
mockHandleSelect.mockClear();
it("renders a toggle switch to turn readaloud on and off and a select menu to control playback speed", () => {
render(
<ReadAloudMenu
enabled={false}
Expand All @@ -18,13 +16,8 @@ describe("test read aloud menu component", () => {
onPlaybackSpeedSelect={mockHandleSelect}
/>
);
});

it("renders a toggle switch that lets a user turn read-aloud mode on and off", () => {
const readAloudMenu = screen.getByRole("menu");
expect(readAloudMenu).toBeInTheDocument();
const readAloudToggle = screen.getByTestId("readaloud-toggle");
expect(readAloudToggle).toBeInTheDocument();
expect(readAloudToggle).toHaveAttribute("type", "checkbox");
expect(readAloudToggle).toHaveAttribute("role", "switch");
expect(readAloudToggle).toHaveAttribute("aria-checked", "false");
Expand All @@ -33,9 +26,7 @@ describe("test read aloud menu component", () => {
expect(mockHandleToggle).toHaveBeenCalledTimes(1);
act(() => readAloudToggle.click());
expect(mockHandleToggle).toHaveBeenCalledTimes(2);
});

it("renders a select dropdown that allows a user to select the playback speed of the readaloud", () => {
const readAloudPlaybackSpeed = screen.getByTestId("readaloud-playback-speed");
expect(readAloudPlaybackSpeed).toBeInTheDocument();
expect(readAloudPlaybackSpeed).toHaveAttribute("id", "readaloud-playback-speed");
Expand All @@ -45,21 +36,9 @@ describe("test read aloud menu component", () => {
const option3 = screen.getByTestId("playback-speed-option-3") as HTMLOptionElement;
expect(option3).toHaveValue("1.5");
option3.selected = true;
readAloudPlaybackSpeed.dispatchEvent(new Event('change', { bubbles: true }));
readAloudPlaybackSpeed.dispatchEvent(new Event("change", { bubbles: true }));
});
expect(mockHandleSelect).toHaveBeenCalled();
expect(readAloudPlaybackSpeed).toHaveValue("1.5");
});

it("renders all playback speed options correctly", () => {
const readAloudPlaybackSpeed = screen.getByTestId("readaloud-playback-speed");
expect(readAloudPlaybackSpeed).toBeInTheDocument();
const options = within(readAloudPlaybackSpeed).getAllByRole("option");
expect(options).toHaveLength(4);
expect(options[0]).toHaveValue("0.5");
expect(options[1]).toHaveValue("1");
expect(options[2]).toHaveValue("1.5");
expect(options[3]).toHaveValue("2");
});

});
});

0 comments on commit 4b3bc21

Please sign in to comment.