@typespec/http-specs 0.1.0-alpha.33-dev.5 → 0.1.0-alpha.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/specs/encode/duration/mockapi.d.ts.map +1 -1
- package/dist/specs/encode/duration/mockapi.js +56 -21
- package/dist/specs/encode/duration/mockapi.js.map +1 -1
- package/package.json +13 -13
- package/specs/encode/duration/mockapi.ts +70 -28
- package/temp/.tsbuildinfo +1 -1
- package/manifest.json +0 -11200
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @typespec/http-specs
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.33
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#9785](https://github.com/microsoft/typespec/pull/9785) Add spector case for extensible enum with special word member names
|
|
8
|
+
- [#9660](https://github.com/microsoft/typespec/pull/9660) Add test case for XML model with datetime properties (rfc3339 and rfc7231 encodings)
|
|
9
|
+
- [#9660](https://github.com/microsoft/typespec/pull/9660) Add test case for XML model with enum property
|
|
10
|
+
|
|
11
|
+
### Bump dependencies
|
|
12
|
+
|
|
13
|
+
- [#9838](https://github.com/microsoft/typespec/pull/9838) Upgrade dependencies
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- [#9945](https://github.com/microsoft/typespec/pull/9945) Fix float comparison in duration encode mockapi for query and header params to use numeric comparison instead of string comparison, allowing values like `35625.0` to match `35625`
|
|
18
|
+
|
|
19
|
+
|
|
3
20
|
## 0.1.0-alpha.32
|
|
4
21
|
|
|
5
22
|
### Features
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockapi.d.ts","sourceRoot":"","sources":["../../../../specs/encode/duration/mockapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,eAAe,
|
|
1
|
+
{"version":3,"file":"mockapi.d.ts","sourceRoot":"","sources":["../../../../specs/encode/duration/mockapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,eAAe,EAEhB,MAAM,oBAAoB,CAAC;AAE5B,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAM,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { json, passOnSuccess, } from "@typespec/spec-api";
|
|
1
|
+
import { json, passOnSuccess, ValidationError, } from "@typespec/spec-api";
|
|
2
2
|
export const Scenarios = {};
|
|
3
3
|
function createBodyServerTests(uri, data, value) {
|
|
4
4
|
return passOnSuccess({
|
|
@@ -75,6 +75,29 @@ function createQueryServerTests(uri, paramData, value, collectionFormat) {
|
|
|
75
75
|
kind: "MockApiDefinition",
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
|
+
function createQueryFloatServerTests(uri, paramData, value) {
|
|
79
|
+
return passOnSuccess({
|
|
80
|
+
uri,
|
|
81
|
+
method: "get",
|
|
82
|
+
request: {
|
|
83
|
+
query: paramData,
|
|
84
|
+
},
|
|
85
|
+
response: {
|
|
86
|
+
status: 204,
|
|
87
|
+
},
|
|
88
|
+
handler: (req) => {
|
|
89
|
+
const actual = req.query["input"];
|
|
90
|
+
const actualNum = parseFloat(actual);
|
|
91
|
+
if (isNaN(actualNum) || actualNum !== value) {
|
|
92
|
+
throw new ValidationError(`Expected query param input=${value} but got ${actual}`, String(value), actual);
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
status: 204,
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
kind: "MockApiDefinition",
|
|
99
|
+
});
|
|
100
|
+
}
|
|
78
101
|
Scenarios.Encode_Duration_Query_default = createQueryServerTests("/encode/duration/query/default", {
|
|
79
102
|
input: "P40D",
|
|
80
103
|
}, "P40D");
|
|
@@ -96,27 +119,27 @@ Scenarios.Encode_Duration_Query_float64Seconds = createQueryServerTests("/encode
|
|
|
96
119
|
Scenarios.Encode_Duration_Query_int32Milliseconds = createQueryServerTests("/encode/duration/query/int32-milliseconds", {
|
|
97
120
|
input: 36000,
|
|
98
121
|
}, "36000");
|
|
99
|
-
Scenarios.Encode_Duration_Query_floatMilliseconds =
|
|
122
|
+
Scenarios.Encode_Duration_Query_floatMilliseconds = createQueryFloatServerTests("/encode/duration/query/float-milliseconds", {
|
|
100
123
|
input: 35625,
|
|
101
|
-
},
|
|
102
|
-
Scenarios.Encode_Duration_Query_float64Milliseconds =
|
|
124
|
+
}, 35625);
|
|
125
|
+
Scenarios.Encode_Duration_Query_float64Milliseconds = createQueryFloatServerTests("/encode/duration/query/float64-milliseconds", {
|
|
103
126
|
input: 35625,
|
|
104
|
-
},
|
|
127
|
+
}, 35625);
|
|
105
128
|
Scenarios.Encode_Duration_Query_int32MillisecondsArray = createQueryServerTests("/encode/duration/query/int32-milliseconds-array", {
|
|
106
129
|
input: [36000, 47000].join(","),
|
|
107
130
|
}, ["36000", "47000"], "csv");
|
|
108
131
|
Scenarios.Encode_Duration_Query_int32SecondsLargerUnit = createQueryServerTests("/encode/duration/query/int32-seconds-larger-unit", {
|
|
109
132
|
input: 120,
|
|
110
133
|
}, "120");
|
|
111
|
-
Scenarios.Encode_Duration_Query_floatSecondsLargerUnit =
|
|
134
|
+
Scenarios.Encode_Duration_Query_floatSecondsLargerUnit = createQueryFloatServerTests("/encode/duration/query/float-seconds-larger-unit", {
|
|
112
135
|
input: 150,
|
|
113
|
-
},
|
|
136
|
+
}, 150);
|
|
114
137
|
Scenarios.Encode_Duration_Query_int32MillisecondsLargerUnit = createQueryServerTests("/encode/duration/query/int32-milliseconds-larger-unit", {
|
|
115
138
|
input: 180000,
|
|
116
139
|
}, "180000");
|
|
117
|
-
Scenarios.Encode_Duration_Query_floatMillisecondsLargerUnit =
|
|
140
|
+
Scenarios.Encode_Duration_Query_floatMillisecondsLargerUnit = createQueryFloatServerTests("/encode/duration/query/float-milliseconds-larger-unit", {
|
|
118
141
|
input: 210000,
|
|
119
|
-
},
|
|
142
|
+
}, 210000);
|
|
120
143
|
function createHeaderServerTests(uri, headersData, value) {
|
|
121
144
|
return passOnSuccess({
|
|
122
145
|
uri,
|
|
@@ -130,6 +153,26 @@ function createHeaderServerTests(uri, headersData, value) {
|
|
|
130
153
|
kind: "MockApiDefinition",
|
|
131
154
|
});
|
|
132
155
|
}
|
|
156
|
+
function createHeaderFloatServerTests(uri, value) {
|
|
157
|
+
return passOnSuccess({
|
|
158
|
+
uri,
|
|
159
|
+
method: "get",
|
|
160
|
+
response: {
|
|
161
|
+
status: 204,
|
|
162
|
+
},
|
|
163
|
+
handler: (req) => {
|
|
164
|
+
const actual = req.headers["duration"];
|
|
165
|
+
const actualNum = parseFloat(actual);
|
|
166
|
+
if (isNaN(actualNum) || actualNum !== value) {
|
|
167
|
+
throw new ValidationError(`Expected header duration=${value} but got ${actual}`, String(value), actual);
|
|
168
|
+
}
|
|
169
|
+
return {
|
|
170
|
+
status: 204,
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
kind: "MockApiDefinition",
|
|
174
|
+
});
|
|
175
|
+
}
|
|
133
176
|
Scenarios.Encode_Duration_Header_default = createHeaderServerTests("/encode/duration/header/default", {
|
|
134
177
|
duration: "P40D",
|
|
135
178
|
}, "P40D");
|
|
@@ -151,25 +194,17 @@ Scenarios.Encode_Duration_Header_iso8601Array = createHeaderServerTests("/encode
|
|
|
151
194
|
Scenarios.Encode_Duration_Header_int32Milliseconds = createHeaderServerTests("/encode/duration/header/int32-milliseconds", {
|
|
152
195
|
duration: "36000",
|
|
153
196
|
}, "36000");
|
|
154
|
-
Scenarios.Encode_Duration_Header_floatMilliseconds =
|
|
155
|
-
|
|
156
|
-
}, "35625");
|
|
157
|
-
Scenarios.Encode_Duration_Header_float64Milliseconds = createHeaderServerTests("/encode/duration/header/float64-milliseconds", {
|
|
158
|
-
duration: "35625",
|
|
159
|
-
}, "35625");
|
|
197
|
+
Scenarios.Encode_Duration_Header_floatMilliseconds = createHeaderFloatServerTests("/encode/duration/header/float-milliseconds", 35625);
|
|
198
|
+
Scenarios.Encode_Duration_Header_float64Milliseconds = createHeaderFloatServerTests("/encode/duration/header/float64-milliseconds", 35625);
|
|
160
199
|
Scenarios.Encode_Duration_Header_int32MillisecondsArray = createHeaderServerTests("/encode/duration/header/int32-milliseconds-array", {
|
|
161
200
|
duration: ["36000", "47000"].join(","),
|
|
162
201
|
}, "36000,47000");
|
|
163
202
|
Scenarios.Encode_Duration_Header_int32SecondsLargerUnit = createHeaderServerTests("/encode/duration/header/int32-seconds-larger-unit", {
|
|
164
203
|
duration: "120",
|
|
165
204
|
}, "120");
|
|
166
|
-
Scenarios.Encode_Duration_Header_floatSecondsLargerUnit =
|
|
167
|
-
duration: "150",
|
|
168
|
-
}, "150");
|
|
205
|
+
Scenarios.Encode_Duration_Header_floatSecondsLargerUnit = createHeaderFloatServerTests("/encode/duration/header/float-seconds-larger-unit", 150);
|
|
169
206
|
Scenarios.Encode_Duration_Header_int32MillisecondsLargerUnit = createHeaderServerTests("/encode/duration/header/int32-milliseconds-larger-unit", {
|
|
170
207
|
duration: "180000",
|
|
171
208
|
}, "180000");
|
|
172
|
-
Scenarios.Encode_Duration_Header_floatMillisecondsLargerUnit =
|
|
173
|
-
duration: "210000",
|
|
174
|
-
}, "210000");
|
|
209
|
+
Scenarios.Encode_Duration_Header_floatMillisecondsLargerUnit = createHeaderFloatServerTests("/encode/duration/header/float-milliseconds-larger-unit", 210000);
|
|
175
210
|
//# sourceMappingURL=mockapi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockapi.js","sourceRoot":"","sources":["../../../../specs/encode/duration/mockapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAEJ,aAAa,
|
|
1
|
+
{"version":3,"file":"mockapi.js","sourceRoot":"","sources":["../../../../specs/encode/duration/mockapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,IAAI,EAEJ,aAAa,EAEb,eAAe,GAChB,MAAM,oBAAoB,CAAC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@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http-specs",
|
|
3
3
|
"displayName": "Http Specs",
|
|
4
|
-
"version": "0.1.0-alpha.33
|
|
4
|
+
"version": "0.1.0-alpha.33",
|
|
5
5
|
"description": "Spec scenarios and mock apis",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
@@ -22,27 +22,27 @@
|
|
|
22
22
|
},
|
|
23
23
|
"homepage": "https://github.com/microsoft/typespec#readme",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"
|
|
26
|
-
"@typespec/spector": "^0.1.0-alpha.
|
|
27
|
-
"
|
|
25
|
+
"deep-equal": "^2.2.0",
|
|
26
|
+
"@typespec/spector": "^0.1.0-alpha.24",
|
|
27
|
+
"@typespec/spec-api": "^0.1.0-alpha.13"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/deep-equal": "^1.0.1",
|
|
31
31
|
"@types/multer": "^2.0.0",
|
|
32
32
|
"@types/node": "~25.3.0",
|
|
33
|
-
"@typespec/json-schema": "^1.9.0 || >= 1.10.0-dev.3",
|
|
34
|
-
"@typespec/openapi": "^1.9.0 || >= 1.10.0-dev.4",
|
|
35
|
-
"@typespec/openapi3": "^1.9.0 || >= 1.10.0-dev.8",
|
|
36
33
|
"concurrently": "^9.1.2",
|
|
37
34
|
"rimraf": "~6.1.3",
|
|
38
|
-
"typescript": "~5.9.3"
|
|
35
|
+
"typescript": "~5.9.3",
|
|
36
|
+
"@typespec/json-schema": "^1.10.0",
|
|
37
|
+
"@typespec/openapi": "^1.10.0",
|
|
38
|
+
"@typespec/openapi3": "^1.10.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@typespec/compiler": "^1.
|
|
42
|
-
"@typespec/http": "^1.
|
|
43
|
-
"@typespec/rest": "^0.
|
|
44
|
-
"@typespec/versioning": "^0.
|
|
45
|
-
"@typespec/xml": "^0.
|
|
41
|
+
"@typespec/compiler": "^1.10.0",
|
|
42
|
+
"@typespec/http": "^1.10.0",
|
|
43
|
+
"@typespec/rest": "^0.80.0",
|
|
44
|
+
"@typespec/versioning": "^0.80.0",
|
|
45
|
+
"@typespec/xml": "^0.80.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
MockRequest,
|
|
5
5
|
passOnSuccess,
|
|
6
6
|
ScenarioMockApi,
|
|
7
|
+
ValidationError,
|
|
7
8
|
} from "@typespec/spec-api";
|
|
8
9
|
|
|
9
10
|
export const Scenarios: Record<string, ScenarioMockApi> = {};
|
|
@@ -146,6 +147,34 @@ function createQueryServerTests(
|
|
|
146
147
|
kind: "MockApiDefinition",
|
|
147
148
|
});
|
|
148
149
|
}
|
|
150
|
+
|
|
151
|
+
function createQueryFloatServerTests(uri: string, paramData: any, value: number) {
|
|
152
|
+
return passOnSuccess({
|
|
153
|
+
uri,
|
|
154
|
+
method: "get",
|
|
155
|
+
request: {
|
|
156
|
+
query: paramData,
|
|
157
|
+
},
|
|
158
|
+
response: {
|
|
159
|
+
status: 204,
|
|
160
|
+
},
|
|
161
|
+
handler: (req: MockRequest) => {
|
|
162
|
+
const actual = req.query["input"] as string;
|
|
163
|
+
const actualNum = parseFloat(actual);
|
|
164
|
+
if (isNaN(actualNum) || actualNum !== value) {
|
|
165
|
+
throw new ValidationError(
|
|
166
|
+
`Expected query param input=${value} but got ${actual}`,
|
|
167
|
+
String(value),
|
|
168
|
+
actual,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
status: 204,
|
|
173
|
+
};
|
|
174
|
+
},
|
|
175
|
+
kind: "MockApiDefinition",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
149
178
|
Scenarios.Encode_Duration_Query_default = createQueryServerTests(
|
|
150
179
|
"/encode/duration/query/default",
|
|
151
180
|
{
|
|
@@ -197,19 +226,19 @@ Scenarios.Encode_Duration_Query_int32Milliseconds = createQueryServerTests(
|
|
|
197
226
|
},
|
|
198
227
|
"36000",
|
|
199
228
|
);
|
|
200
|
-
Scenarios.Encode_Duration_Query_floatMilliseconds =
|
|
229
|
+
Scenarios.Encode_Duration_Query_floatMilliseconds = createQueryFloatServerTests(
|
|
201
230
|
"/encode/duration/query/float-milliseconds",
|
|
202
231
|
{
|
|
203
232
|
input: 35625,
|
|
204
233
|
},
|
|
205
|
-
|
|
234
|
+
35625,
|
|
206
235
|
);
|
|
207
|
-
Scenarios.Encode_Duration_Query_float64Milliseconds =
|
|
236
|
+
Scenarios.Encode_Duration_Query_float64Milliseconds = createQueryFloatServerTests(
|
|
208
237
|
"/encode/duration/query/float64-milliseconds",
|
|
209
238
|
{
|
|
210
239
|
input: 35625,
|
|
211
240
|
},
|
|
212
|
-
|
|
241
|
+
35625,
|
|
213
242
|
);
|
|
214
243
|
Scenarios.Encode_Duration_Query_int32MillisecondsArray = createQueryServerTests(
|
|
215
244
|
"/encode/duration/query/int32-milliseconds-array",
|
|
@@ -226,12 +255,12 @@ Scenarios.Encode_Duration_Query_int32SecondsLargerUnit = createQueryServerTests(
|
|
|
226
255
|
},
|
|
227
256
|
"120",
|
|
228
257
|
);
|
|
229
|
-
Scenarios.Encode_Duration_Query_floatSecondsLargerUnit =
|
|
258
|
+
Scenarios.Encode_Duration_Query_floatSecondsLargerUnit = createQueryFloatServerTests(
|
|
230
259
|
"/encode/duration/query/float-seconds-larger-unit",
|
|
231
260
|
{
|
|
232
261
|
input: 150,
|
|
233
262
|
},
|
|
234
|
-
|
|
263
|
+
150,
|
|
235
264
|
);
|
|
236
265
|
Scenarios.Encode_Duration_Query_int32MillisecondsLargerUnit = createQueryServerTests(
|
|
237
266
|
"/encode/duration/query/int32-milliseconds-larger-unit",
|
|
@@ -240,12 +269,12 @@ Scenarios.Encode_Duration_Query_int32MillisecondsLargerUnit = createQueryServerT
|
|
|
240
269
|
},
|
|
241
270
|
"180000",
|
|
242
271
|
);
|
|
243
|
-
Scenarios.Encode_Duration_Query_floatMillisecondsLargerUnit =
|
|
272
|
+
Scenarios.Encode_Duration_Query_floatMillisecondsLargerUnit = createQueryFloatServerTests(
|
|
244
273
|
"/encode/duration/query/float-milliseconds-larger-unit",
|
|
245
274
|
{
|
|
246
275
|
input: 210000,
|
|
247
276
|
},
|
|
248
|
-
|
|
277
|
+
210000,
|
|
249
278
|
);
|
|
250
279
|
|
|
251
280
|
function createHeaderServerTests(uri: string, headersData: any, value: any) {
|
|
@@ -262,6 +291,31 @@ function createHeaderServerTests(uri: string, headersData: any, value: any) {
|
|
|
262
291
|
});
|
|
263
292
|
}
|
|
264
293
|
|
|
294
|
+
function createHeaderFloatServerTests(uri: string, value: number) {
|
|
295
|
+
return passOnSuccess({
|
|
296
|
+
uri,
|
|
297
|
+
method: "get",
|
|
298
|
+
response: {
|
|
299
|
+
status: 204,
|
|
300
|
+
},
|
|
301
|
+
handler: (req: MockRequest) => {
|
|
302
|
+
const actual = req.headers["duration"];
|
|
303
|
+
const actualNum = parseFloat(actual);
|
|
304
|
+
if (isNaN(actualNum) || actualNum !== value) {
|
|
305
|
+
throw new ValidationError(
|
|
306
|
+
`Expected header duration=${value} but got ${actual}`,
|
|
307
|
+
String(value),
|
|
308
|
+
actual,
|
|
309
|
+
);
|
|
310
|
+
}
|
|
311
|
+
return {
|
|
312
|
+
status: 204,
|
|
313
|
+
};
|
|
314
|
+
},
|
|
315
|
+
kind: "MockApiDefinition",
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
|
|
265
319
|
Scenarios.Encode_Duration_Header_default = createHeaderServerTests(
|
|
266
320
|
"/encode/duration/header/default",
|
|
267
321
|
{
|
|
@@ -312,19 +366,13 @@ Scenarios.Encode_Duration_Header_int32Milliseconds = createHeaderServerTests(
|
|
|
312
366
|
},
|
|
313
367
|
"36000",
|
|
314
368
|
);
|
|
315
|
-
Scenarios.Encode_Duration_Header_floatMilliseconds =
|
|
369
|
+
Scenarios.Encode_Duration_Header_floatMilliseconds = createHeaderFloatServerTests(
|
|
316
370
|
"/encode/duration/header/float-milliseconds",
|
|
317
|
-
|
|
318
|
-
duration: "35625",
|
|
319
|
-
},
|
|
320
|
-
"35625",
|
|
371
|
+
35625,
|
|
321
372
|
);
|
|
322
|
-
Scenarios.Encode_Duration_Header_float64Milliseconds =
|
|
373
|
+
Scenarios.Encode_Duration_Header_float64Milliseconds = createHeaderFloatServerTests(
|
|
323
374
|
"/encode/duration/header/float64-milliseconds",
|
|
324
|
-
|
|
325
|
-
duration: "35625",
|
|
326
|
-
},
|
|
327
|
-
"35625",
|
|
375
|
+
35625,
|
|
328
376
|
);
|
|
329
377
|
Scenarios.Encode_Duration_Header_int32MillisecondsArray = createHeaderServerTests(
|
|
330
378
|
"/encode/duration/header/int32-milliseconds-array",
|
|
@@ -340,12 +388,9 @@ Scenarios.Encode_Duration_Header_int32SecondsLargerUnit = createHeaderServerTest
|
|
|
340
388
|
},
|
|
341
389
|
"120",
|
|
342
390
|
);
|
|
343
|
-
Scenarios.Encode_Duration_Header_floatSecondsLargerUnit =
|
|
391
|
+
Scenarios.Encode_Duration_Header_floatSecondsLargerUnit = createHeaderFloatServerTests(
|
|
344
392
|
"/encode/duration/header/float-seconds-larger-unit",
|
|
345
|
-
|
|
346
|
-
duration: "150",
|
|
347
|
-
},
|
|
348
|
-
"150",
|
|
393
|
+
150,
|
|
349
394
|
);
|
|
350
395
|
Scenarios.Encode_Duration_Header_int32MillisecondsLargerUnit = createHeaderServerTests(
|
|
351
396
|
"/encode/duration/header/int32-milliseconds-larger-unit",
|
|
@@ -354,10 +399,7 @@ Scenarios.Encode_Duration_Header_int32MillisecondsLargerUnit = createHeaderServe
|
|
|
354
399
|
},
|
|
355
400
|
"180000",
|
|
356
401
|
);
|
|
357
|
-
Scenarios.Encode_Duration_Header_floatMillisecondsLargerUnit =
|
|
402
|
+
Scenarios.Encode_Duration_Header_floatMillisecondsLargerUnit = createHeaderFloatServerTests(
|
|
358
403
|
"/encode/duration/header/float-milliseconds-larger-unit",
|
|
359
|
-
|
|
360
|
-
duration: "210000",
|
|
361
|
-
},
|
|
362
|
-
"210000",
|
|
404
|
+
210000,
|
|
363
405
|
);
|