|
| 1 | +import { describe, expect, it } from "@jest/globals"; |
| 2 | +import { getMediaUrl } from "."; |
| 3 | + |
| 4 | +describe("utilities", () => { |
| 5 | + describe("getMediaUrl", () => { |
| 6 | + it("use no url", () => { |
| 7 | + // @ts-expect-error cope with no arguments |
| 8 | + expect(getMediaUrl()).toBe(""); |
| 9 | + }); |
| 10 | + |
| 11 | + it("use full url", () => { |
| 12 | + expect(getMediaUrl("http://localhost:3000")).toBe( |
| 13 | + "http://localhost:3000", |
| 14 | + ); |
| 15 | + }); |
| 16 | + |
| 17 | + it("use full url with cacheTag", () => { |
| 18 | + expect(getMediaUrl("http://localhost:3000", "tag=tag")).toBe( |
| 19 | + "http://localhost:3000?tag=tag", |
| 20 | + ); |
| 21 | + }); |
| 22 | + |
| 23 | + it("use client browser plus endpoint", () => { |
| 24 | + Object.defineProperty(window, "location", { |
| 25 | + value: new URL("http://localhost:3000"), |
| 26 | + }); |
| 27 | + |
| 28 | + expect(getMediaUrl("/foo")).toBe("http://localhost:3000/foo"); |
| 29 | + }); |
| 30 | + |
| 31 | + it("use client browser plus endpoint with cacheTage", () => { |
| 32 | + Object.defineProperty(window, "location", { |
| 33 | + value: new URL("http://localhost:3000"), |
| 34 | + }); |
| 35 | + |
| 36 | + expect(getMediaUrl("/foo", "tag=tag")).toBe( |
| 37 | + "http://localhost:3000/foo?tag=tag", |
| 38 | + ); |
| 39 | + }); |
| 40 | + }); |
| 41 | +}); |
0 commit comments