7
7
8
8
import { assert , describe , it } from "vitest" ;
9
9
10
- import { DateOnly , HttpMethod , type Guid , type Parsable , parseGuidString , type RequestAdapter , RequestInformation , type SerializationWriter , type SerializationWriterFactory , TimeOnly } from "../../src" ;
10
+ import { DateOnly , HttpMethod , type Guid , type Parsable , parseGuidString , type RequestAdapter , RequestInformation , type SerializationWriter , type SerializationWriterFactory , TimeOnly , Duration } from "../../src" ;
11
11
import { MultipartBody } from "../../src/multipartBody" ;
12
12
import { TestEnum } from "./store/testEnum" ;
13
13
@@ -25,6 +25,8 @@ interface GetQueryParameters {
25
25
endTime ?: TimeOnly ;
26
26
endDate ?: DateOnly ;
27
27
timeStamp ?: Date ;
28
+ time ?: TimeOnly ;
29
+ duration ?: Duration ;
28
30
}
29
31
30
32
const getQueryParameterMapper : Record < string , string > = {
@@ -221,13 +223,13 @@ describe("RequestInformation", () => {
221
223
} ) ;
222
224
223
225
it ( "should correctly handle custom type in query/path parameter" , ( ) => {
224
- const expected : string = `http://localhost/users/33933a8d-32bb-c6a8-784a-f60b5a1dd66a/2021-12-12?objectId=83afbf49-5583-152c-d7fb-176105d518bc&startDate=2021-12-12&startTime=23%3A12%3A00.0000000&timeStamp=2024-06-11T00%3A00%3A00.000Z` ;
226
+ const expected : string = `http://localhost/users/33933a8d-32bb-c6a8-784a-f60b5a1dd66a/2021-12-12?objectId=83afbf49-5583-152c-d7fb-176105d518bc&startDate=2021-12-12&startTime=23%3A12%3A00.0000000&timeStamp=2024-06-11T00%3A00%3A00.000Z&duration=P1D&time=23:12:00.0000000 ` ;
225
227
const requestInformation = new RequestInformation ( HttpMethod . GET ) ;
226
228
requestInformation . pathParameters [ "baseurl" ] = baseUrl ;
227
229
requestInformation . pathParameters [ "userId" ] = parseGuidString ( "33933a8d-32bb-c6a8-784a-f60b5a1dd66a" ) ;
228
230
requestInformation . pathParameters [ "date" ] = DateOnly . parse ( "2021-12-12" ) ;
229
- requestInformation . urlTemplate = "http://localhost/users/{userId}/{date}{?objectId,startDate,startTime,endDate,endTime,timeStamp}" ;
230
- requestInformation . setQueryStringParametersFromRawObject < GetQueryParameters > ( { objectId : parseGuidString ( "83afbf49-5583-152c-d7fb-176105d518bc" ) , startDate : new DateOnly ( { year : 2021 , month : 12 , day : 12 } ) , startTime : new TimeOnly ( { hours : 23 , minutes : 12 } ) , timeStamp : new Date ( "2024-06-11T00:00:00.000Z" ) } , getQueryParameterMapper ) ;
231
+ requestInformation . urlTemplate = "http://localhost/users/{userId}/{date}{?objectId,startDate,startTime,endDate,endTime,timeStamp,duration }" ;
232
+ requestInformation . setQueryStringParametersFromRawObject < GetQueryParameters > ( { objectId : parseGuidString ( "83afbf49-5583-152c-d7fb-176105d518bc" ) , startDate : new DateOnly ( { year : 2021 , month : 12 , day : 12 } ) , startTime : new TimeOnly ( { hours : 23 , minutes : 12 } ) , timeStamp : new Date ( "2024-06-11T00:00:00.000Z" ) , duration : Duration . parse ( "P1D" ) , time : TimeOnly . parse ( "23:12:00.0000000" ) } , getQueryParameterMapper ) ;
231
233
assert . equal ( requestInformation . URL , expected ) ;
232
234
} ) ;
233
235
0 commit comments