* feat: add `PlayPauseButton` to storybook * feat: add generic media body * feat: add seekbar component * chore: add ViewWrapper to help writing stories with vm * refactor: move `formatBytes` from `formattingUtils` into shared component * refactor: add `className` props to `Clock` * feat: add new audio player component * test(e2e): add screenshots for new shared components * feat: add AudioPlayerViewModel * feat: use new audio player in `MAudioBody` * refactor: remove old audio player * test(e2e): update existing tests * refactor: remove unused `DurationClock` * refactor: rename `SeekBar` into `LegacySeekBar`
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
/*
|
|
* Copyright 2025 New Vector Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { composeStories } from "@storybook/react-vite";
|
|
import { render } from "jest-matrix-react";
|
|
import React from "react";
|
|
import userEvent from "@testing-library/user-event";
|
|
import { fn } from "storybook/test";
|
|
|
|
import * as stories from "./PlayPauseButton.stories.tsx";
|
|
|
|
const { Default, Playing } = composeStories(stories);
|
|
|
|
describe("PlayPauseButton", () => {
|
|
it("renders the button in default state", () => {
|
|
const { container } = render(<Default />);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it("renders the button in playing state", () => {
|
|
const { container } = render(<Playing />);
|
|
expect(container).toMatchSnapshot();
|
|
});
|
|
|
|
it("calls togglePlay when clicked", async () => {
|
|
const user = userEvent.setup();
|
|
const togglePlay = fn();
|
|
|
|
const { getByRole } = render(<Default togglePlay={togglePlay} />);
|
|
await user.click(getByRole("button"));
|
|
expect(togglePlay).toHaveBeenCalled();
|
|
});
|
|
});
|