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,7 @@ interface GetQueryParameters {
25
25
endTime ?: TimeOnly ;
26
26
endDate ?: DateOnly ;
27
27
timeStamp ?: Date ;
28
+ duration ?: Duration ;
28
29
}
29
30
30
31
const getQueryParameterMapper : Record < string , string > = {
@@ -221,13 +222,13 @@ describe("RequestInformation", () => {
221
222
} ) ;
222
223
223
224
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` ;
225
+ 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 ` ;
225
226
const requestInformation = new RequestInformation ( HttpMethod . GET ) ;
226
227
requestInformation . pathParameters [ "baseurl" ] = baseUrl ;
227
228
requestInformation . pathParameters [ "userId" ] = parseGuidString ( "33933a8d-32bb-c6a8-784a-f60b5a1dd66a" ) ;
228
229
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 ) ;
230
+ requestInformation . urlTemplate = "http://localhost/users/{userId}/{date}{?objectId,startDate,startTime,endDate,endTime,timeStamp,duration }" ;
231
+ 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" ) } , getQueryParameterMapper ) ;
231
232
assert . equal ( requestInformation . URL , expected ) ;
232
233
} ) ;
233
234
0 commit comments