1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

Show initial broadcast position in seekbar (#9796)

This commit is contained in:
Michael Weimann
2022-12-22 15:30:42 +01:00
committed by GitHub
parent e9224f6fce
commit b07bd4d102
3 changed files with 40 additions and 13 deletions

View File

@@ -42,24 +42,36 @@ describe("SeekBar", () => {
});
describe("when rendering a SeekBar", () => {
beforeEach(async () => {
beforeEach(() => {
renderResult = render(<SeekBar ref={seekBarRef} playback={playback} />);
act(() => {
playback.liveData.update([playback.timeSeconds, playback.durationSeconds]);
frameRequestCallback(0);
});
});
it("should render as expected", () => {
it("should render the initial position", () => {
// expected value 3141 / 31415 ~ 0.099984084
expect(renderResult.container).toMatchSnapshot();
});
describe("and the playback proceeds", () => {
beforeEach(async () => {
// @ts-ignore
playback.timeSeconds = 6969;
act(() => {
playback.liveData.update([playback.timeSeconds, playback.durationSeconds]);
frameRequestCallback(0);
});
});
it("should render as expected", () => {
// expected value 6969 / 31415 ~ 0.221836702
expect(renderResult.container).toMatchSnapshot();
});
});
describe("and seeking position with the slider", () => {
beforeEach(() => {
const rangeInput = renderResult.container.querySelector("[type='range']");
act(() => {
fireEvent.change(rangeInput, { target: { value: 0.5 } });
fireEvent.change(rangeInput!, { target: { value: 0.5 } });
});
});
@@ -71,7 +83,7 @@ describe("SeekBar", () => {
beforeEach(() => {
mocked(playback.skipTo).mockClear();
act(() => {
seekBarRef.current.left();
seekBarRef.current!.left();
});
});
@@ -84,7 +96,7 @@ describe("SeekBar", () => {
beforeEach(() => {
mocked(playback.skipTo).mockClear();
act(() => {
seekBarRef.current.right();
seekBarRef.current!.right();
});
});