Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Jan 29, 2024
1 parent 67e5410 commit e6ff388
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { GetVideoClassName } from "./get-video-class-name";

describe("GetVideoClassName function", () => {
it('should return "video play" when paused and started', () => {
const isPaused = true;
const isStarted = true;

const result = GetVideoClassName(isPaused, isStarted);

expect(result).toBe("video play");
});

it('should return "video first" when paused and not started', () => {
const isPaused = true;
const isStarted = false;

const result = GetVideoClassName(isPaused, isStarted);

expect(result).toBe("video first");
});

it('should return "video pause" when not paused', () => {
const isPaused = false;
const isStarted = true;

const result = GetVideoClassName(isPaused, isStarted);

expect(result).toBe("video pause");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,29 @@ describe("TimeUpdate function", () => {
expect(secondsToHoursSpy).toHaveBeenCalledTimes(2); // Once for current time, once for duration
});

// it("should set max attribute for progress element if not set", () => {
// // Set up valid values for refs
// videoRef.current.duration = 100;
it("should set max attribute for progress element if not set", () => {
// Set up valid values for refs
videoRef = {
current: {
duration: 100
} as any
};

// // Remove the max attribute from the progress element
// progressRef.current.removeAttribute("max");
const setAttributeSpy = jest.fn();
progressRef = {
current: {
value: 0,
getAttribute: jest.fn(),
setAttribute: setAttributeSpy
} as any
};

// act(() => {
// TimeUpdate(videoRef, setIsLoadingMock, progressRef, scrubberRef, timeRef);
// });
act(() => {
TimeUpdate(videoRef, setIsLoadingMock, progressRef, scrubberRef, timeRef);
});

// // Assert that max attribute was set
// expect(progressRef.current.getAttribute("max")).toBe("100");
// });
// Assert that max attribute was set
expect(setAttributeSpy).toHaveBeenCalledTimes(1);
expect(setAttributeSpy).toHaveBeenCalledWith("max", "100");
});
});

0 comments on commit e6ff388

Please sign in to comment.