Skip to content

Commit 7b3cdce

Browse files
committed
fix
1 parent 3c9ed32 commit 7b3cdce

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

site/src/modules/dashboard/Navbar/MobileMenu.test.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import { includeOrigin } from "./MobileMenu";
22

3+
const mockOrigin = "https://example.com";
4+
35
describe("support link", () => {
46
it("should include origin if target starts with '/'", () => {
5-
const mockOrigin = "https://example.com";
6-
7-
window.location = { origin: mockOrigin }; // Mock the location origin
7+
(window as unknown as { location: Partial<Location> }).location = { origin: mockOrigin }; // Mock the location origin
88

9-
expect(includeOrigin("/test")).toBe("https://example.com/test");
9+
expect(includeOrigin("/test")).toBe(mockOrigin + "/test");
1010
expect(includeOrigin("/path/to/resource")).toBe(
11-
"https://example.com/path/to/resource",
11+
mockOrigin + "/path/to/resource",
1212
);
1313
});
1414

1515
it("should return the target unchanged if it does not start with '/'", () => {
16-
expect(includeOrigin("https://example.com/page")).toBe(
17-
"https://example.com/page",
18-
);
16+
expect(includeOrigin(mockOrigin + "/page")).toBe(mockOrigin + "/page");
1917
expect(includeOrigin("../relative/path")).toBe("../relative/path");
2018
expect(includeOrigin("relative/path")).toBe("relative/path");
2119
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy