File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
site/src/modules/dashboard/Navbar Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { includeOrigin } from "./MobileMenu" ;
2
2
3
+ const mockOrigin = "https://example.com" ;
4
+
3
5
describe ( "support link" , ( ) => {
4
6
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
8
8
9
- expect ( includeOrigin ( "/test" ) ) . toBe ( "https://example.com /test") ;
9
+ expect ( includeOrigin ( "/test" ) ) . toBe ( mockOrigin + " /test") ;
10
10
expect ( includeOrigin ( "/path/to/resource" ) ) . toBe (
11
- "https://example.com /path/to/resource",
11
+ mockOrigin + " /path/to/resource",
12
12
) ;
13
13
} ) ;
14
14
15
15
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" ) ;
19
17
expect ( includeOrigin ( "../relative/path" ) ) . toBe ( "../relative/path" ) ;
20
18
expect ( includeOrigin ( "relative/path" ) ) . toBe ( "relative/path" ) ;
21
19
} ) ;
You can’t perform that action at this time.
0 commit comments