File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from "vitest" ;
2+ import { getRequestURL } from "./index" ;
3+
4+ describe ( "getUrl" , ( ) => {
5+ it ( "should return URL object for the request" , ( ) => {
6+ const request = new Request ( "https://example.com/path?query=test" ) ;
7+ const url = getRequestURL ( request ) ;
8+ expect ( url ) . toBeInstanceOf ( URL ) ;
9+ expect ( url . href ) . toBe ( "https://example.com/path?query=test" ) ;
10+ } ) ;
11+
12+ it ( "should cache URL object on subsequent calls" , ( ) => {
13+ const request = new Request ( "https://example.com/path?query=test" ) ;
14+ const firstUrl = getRequestURL ( request ) ;
15+ const secondUrl = getRequestURL ( request ) ;
16+ expect ( firstUrl ) . toBe ( secondUrl ) ;
17+ } ) ;
18+
19+ it ( "should handle different request URLs" , ( ) => {
20+ const request1 = new Request ( "https://example.com/path1" ) ;
21+ const request2 = new Request ( "https://example.com/path2" ) ;
22+
23+ const url1 = getRequestURL ( request1 ) ;
24+ const url2 = getRequestURL ( request2 ) ;
25+
26+ expect ( url1 . pathname ) . toBe ( "/path1" ) ;
27+ expect ( url2 . pathname ) . toBe ( "/path2" ) ;
28+ } ) ;
29+ } ) ;
You can’t perform that action at this time.
0 commit comments