2021-10-02 23:13:30 +02:00
|
|
|
import { getStartTimeFromUrl } from '../src/utils/urlParser';
|
|
|
|
|
|
|
|
describe("getStartTimeFromUrl", () => {
|
|
|
|
it("parses with a number", () => {
|
|
|
|
expect(getStartTimeFromUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=123")).toBe(123);
|
|
|
|
});
|
|
|
|
|
2021-10-06 02:51:20 +02:00
|
|
|
it("parses with seconds", () => {
|
2021-10-02 23:13:30 +02:00
|
|
|
expect(getStartTimeFromUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=123s")).toBe(123);
|
|
|
|
});
|
|
|
|
|
2021-10-06 02:51:20 +02:00
|
|
|
it("parses with minutes", () => {
|
2021-10-02 23:13:30 +02:00
|
|
|
expect(getStartTimeFromUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=23m3s")).toBe(23 * 60 + 3);
|
|
|
|
});
|
|
|
|
|
2021-10-06 02:51:20 +02:00
|
|
|
it("parses with hours", () => {
|
2021-10-02 23:13:30 +02:00
|
|
|
expect(getStartTimeFromUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ&t=1h2m3s")).toBe(1 * 60 * 60 + 2 * 60 + 3);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("works with time_continue", () => {
|
|
|
|
expect(getStartTimeFromUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ&time_continue=123")).toBe(123);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("works with no time", () => {
|
|
|
|
expect(getStartTimeFromUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")).toBe(0);
|
|
|
|
});
|
|
|
|
});
|