@api-client/core 0.14.10 → 0.15.0
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/RELEASE.md +163 -0
- package/RELEASE_SETUP.md +235 -0
- package/build/src/events/authorization/AuthorizationEvents.d.ts +1 -1
- package/build/src/events/authorization/AuthorizationEvents.d.ts.map +1 -1
- package/build/src/events/authorization/AuthorizationEvents.js +1 -1
- package/build/src/events/authorization/AuthorizationEvents.js.map +1 -1
- package/build/src/events/cookies/CookieEvents.d.ts +1 -1
- package/build/src/events/cookies/CookieEvents.d.ts.map +1 -1
- package/build/src/events/cookies/CookieEvents.js +1 -1
- package/build/src/events/cookies/CookieEvents.js.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.d.ts +22 -119
- package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
- package/build/src/modeling/DomainImpactAnalysis.js +49 -155
- package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
- package/build/src/modeling/DomainValidation.d.ts +8 -0
- package/build/src/modeling/DomainValidation.d.ts.map +1 -0
- package/build/src/modeling/DomainValidation.js +99 -0
- package/build/src/modeling/DomainValidation.js.map +1 -0
- package/build/src/modeling/types.d.ts +70 -0
- package/build/src/modeling/types.d.ts.map +1 -1
- package/build/src/modeling/types.js.map +1 -1
- package/build/src/modeling/validation/rules.d.ts +2 -3
- package/build/src/modeling/validation/rules.d.ts.map +1 -1
- package/build/src/modeling/validation/rules.js.map +1 -1
- package/build/src/modeling/validation/semantic_validation.d.ts +31 -0
- package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -0
- package/build/src/modeling/validation/semantic_validation.js +126 -0
- package/build/src/modeling/validation/semantic_validation.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/noop.ts +3 -0
- package/package.json +9 -4
- package/src/events/authorization/AuthorizationEvents.ts +1 -1
- package/src/events/cookies/CookieEvents.ts +1 -1
- package/src/modeling/DomainImpactAnalysis.ts +54 -239
- package/src/modeling/DomainValidation.ts +105 -0
- package/src/modeling/types.ts +86 -0
- package/src/modeling/validation/rules.ts +2 -4
- package/src/modeling/validation/semantic_validation.ts +145 -0
- package/tests/unit/events/EventsTestHelpers.ts +16 -0
- package/tests/unit/events/amf.spec.ts +151 -0
- package/tests/unit/events/authorization.spec.ts +150 -0
- package/tests/unit/events/cookie.spec.ts +274 -0
- package/tests/unit/events/encryption.spec.ts +108 -0
- package/tests/unit/events/events_polyfills.ts +77 -0
- package/tests/unit/events/process.spec.ts +120 -0
- package/tests/unit/events/reporting.spec.ts +82 -0
- package/tests/unit/events/telemetry.spec.ts +224 -0
- package/tests/unit/events/transport.spec.ts +139 -0
- package/tests/unit/modeling/domain_impact_analysis.spec.ts +0 -110
- package/tests/unit/modeling/domain_validation.spec.ts +94 -0
- package/tests/unit/modeling/validation/semantic_validation.spec.ts +91 -0
- package/tests/unit/models/environment.spec.ts +574 -0
- package/tests/unit/models/error_response.spec.ts +183 -0
- package/tests/unit/models/headers_array.spec.ts +86 -0
- package/tests/unit/models/http-actions/assertion/equal_assertion.spec.ts +103 -0
- package/tests/unit/models/http-actions/assertion/greater_than_assertion.spec.ts +91 -0
- package/tests/unit/models/http-actions/assertion/includes_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/assertion/less_than_assertion.spec.ts +91 -0
- package/tests/unit/models/http-actions/assertion/matches_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/assertion/matches_schema_assertion.spec.ts +117 -0
- package/tests/unit/models/http-actions/assertion/not_equal_assertion.spec.ts +103 -0
- package/tests/unit/models/http-actions/assertion/not_includes_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/assertion/not_ok_assertion.spec.ts +47 -0
- package/tests/unit/models/http-actions/assertion/not_to_be_assertion.spec.ts +72 -0
- package/tests/unit/models/http-actions/assertion/ok_assertion.spec.ts +44 -0
- package/tests/unit/models/http-actions/assertion/to_be_assertion.spec.ts +71 -0
- package/tests/unit/models/http-actions/transformation/as_lower_case_step.spec.ts +47 -0
- package/tests/unit/models/http-actions/transformation/as_number_step.spec.ts +47 -0
- package/tests/unit/models/http-actions/transformation/as_upper_case_step.spec.ts +47 -0
- package/tests/unit/models/http-actions/transformation/round_step.spec.ts +69 -0
- package/tests/unit/models/http-actions/transformation/substring_step.spec.ts +85 -0
- package/tests/unit/models/http-actions/transformation/trim_step.spec.ts +44 -0
- package/tests/unit/models/http_cookie.spec.ts +516 -0
- package/tests/unit/models/http_history.spec.ts +443 -0
- package/tests/unit/models/project_folder.spec.ts +926 -0
- package/tests/unit/models/project_item.spec.ts +137 -0
- package/tests/unit/models/project_request.spec.ts +1047 -0
- package/tests/unit/models/project_schema.spec.ts +236 -0
- package/tests/unit/models/property.spec.ts +625 -0
- package/tests/unit/models/provider.spec.ts +102 -0
- package/tests/unit/models/request.spec.ts +1206 -0
- package/tests/unit/models/request_log.spec.ts +308 -0
- package/tests/unit/models/request_time.spec.ts +138 -0
- package/tests/unit/models/response_redirect.spec.ts +303 -0
- package/tests/unit/models/sent_request.spec.ts +206 -0
- package/tests/unit/models/server.spec.ts +195 -0
- package/tests/unit/models/thing.spec.ts +154 -0
- package/build/oauth-popup.html +0 -33
- /package/tests/unit/models/{Certificate.spec.ts → certificate.spec.ts} +0 -0
- /package/tests/unit/models/{HostRule.spec.ts → host_rule.spec.ts} +0 -0
- /package/tests/unit/models/{HttpProject.spec.ts → http_project.spec.ts} +0 -0
- /package/tests/unit/models/{HttpRequest.spec.ts → http_request.spec.ts} +0 -0
- /package/tests/unit/models/{HttpResponse.spec.ts → http_response.spec.ts} +0 -0
- /package/tests/unit/models/{License.spec.ts → license.spec.ts} +0 -0
- /package/tests/unit/models/{Response.spec.ts → response.spec.ts} +0 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { RequestLog, IRequestLog, Kind as RequestLogKind } from '../../../src/models/RequestLog.js'
|
|
3
|
+
import { ISentRequest, SentRequest } from '../../../src/models/SentRequest.js'
|
|
4
|
+
import { IResponse, Response } from '../../../src/models/Response.js'
|
|
5
|
+
import {
|
|
6
|
+
IResponseRedirect,
|
|
7
|
+
Kind as HttpResponseRedirectKind,
|
|
8
|
+
ResponseRedirect,
|
|
9
|
+
} from '../../../src/models/ResponseRedirect.js'
|
|
10
|
+
import { ResponseRedirect as LegacyRedirect } from '../../../src/models/legacy/request/ArcResponse.js'
|
|
11
|
+
|
|
12
|
+
test.group('Models > RequestLog > RequestLog.fromRequest()', (group) => {
|
|
13
|
+
let request: ISentRequest
|
|
14
|
+
group.each.setup(() => {
|
|
15
|
+
request = {
|
|
16
|
+
startTime: 1234,
|
|
17
|
+
endTime: 5678,
|
|
18
|
+
url: 'https://dot.com',
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('sets the kind', ({ assert }) => {
|
|
23
|
+
const result = RequestLog.fromRequest(request)
|
|
24
|
+
assert.equal(result.kind, RequestLogKind)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('sets the request', ({ assert }) => {
|
|
28
|
+
const result = RequestLog.fromRequest(request)
|
|
29
|
+
assert.instanceOf(result.request, SentRequest)
|
|
30
|
+
assert.equal(result.request!.url, request.url)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test.group('Models > RequestLog > RequestLog.fromRequestResponse()', (group) => {
|
|
35
|
+
let request: ISentRequest
|
|
36
|
+
let response: IResponse
|
|
37
|
+
group.each.setup(() => {
|
|
38
|
+
request = {
|
|
39
|
+
startTime: 1234,
|
|
40
|
+
endTime: 5678,
|
|
41
|
+
url: 'https://dot.com',
|
|
42
|
+
}
|
|
43
|
+
response = {
|
|
44
|
+
loadingTime: 1,
|
|
45
|
+
status: 200,
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
test('sets the kind', ({ assert }) => {
|
|
50
|
+
const result = RequestLog.fromRequestResponse(request, response)
|
|
51
|
+
assert.equal(result.kind, RequestLogKind)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
test('sets the request', ({ assert }) => {
|
|
55
|
+
const result = RequestLog.fromRequestResponse(request, response)
|
|
56
|
+
assert.instanceOf(result.request, SentRequest)
|
|
57
|
+
assert.equal(result.request!.url, request.url)
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('sets the response', ({ assert }) => {
|
|
61
|
+
const result = RequestLog.fromRequestResponse(request, response)
|
|
62
|
+
assert.instanceOf(result.response, Response)
|
|
63
|
+
assert.equal(result.response!.status, response.status)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test.group('Models > RequestLog > constructor()', () => {
|
|
68
|
+
test('creates default values', ({ assert }) => {
|
|
69
|
+
const result = new RequestLog()
|
|
70
|
+
assert.equal(result.kind, RequestLogKind)
|
|
71
|
+
assert.isUndefined(result.request)
|
|
72
|
+
assert.isUndefined(result.response)
|
|
73
|
+
assert.isUndefined(result.redirects)
|
|
74
|
+
assert.isUndefined(result.size)
|
|
75
|
+
assert.isUndefined(result.assertions)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('creates values from the schema', ({ assert }) => {
|
|
79
|
+
const schema: IRequestLog = {
|
|
80
|
+
kind: RequestLogKind,
|
|
81
|
+
request: {
|
|
82
|
+
startTime: 1234,
|
|
83
|
+
endTime: 5678,
|
|
84
|
+
url: 'https://dot.com',
|
|
85
|
+
},
|
|
86
|
+
response: {
|
|
87
|
+
loadingTime: 1,
|
|
88
|
+
status: 200,
|
|
89
|
+
},
|
|
90
|
+
redirects: [
|
|
91
|
+
{
|
|
92
|
+
startTime: 1234,
|
|
93
|
+
endTime: 5678,
|
|
94
|
+
url: 'https://dot.com',
|
|
95
|
+
response: {
|
|
96
|
+
status: 200,
|
|
97
|
+
},
|
|
98
|
+
kind: HttpResponseRedirectKind,
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
size: {
|
|
102
|
+
request: 123,
|
|
103
|
+
response: 456,
|
|
104
|
+
},
|
|
105
|
+
assertions: [
|
|
106
|
+
{
|
|
107
|
+
description: 't1',
|
|
108
|
+
ok: true,
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
}
|
|
112
|
+
const result = new RequestLog(schema)
|
|
113
|
+
assert.equal(result.kind, RequestLogKind)
|
|
114
|
+
assert.instanceOf(result.request, SentRequest)
|
|
115
|
+
assert.equal(result.request!.url, 'https://dot.com')
|
|
116
|
+
assert.instanceOf(result.response, Response)
|
|
117
|
+
assert.equal(result.response!.status, 200)
|
|
118
|
+
assert.isArray(result.redirects)
|
|
119
|
+
assert.lengthOf(result.redirects!, 1)
|
|
120
|
+
assert.instanceOf(result.redirects![0], ResponseRedirect)
|
|
121
|
+
assert.isObject(result.size)
|
|
122
|
+
assert.equal(result.size!.request, 123)
|
|
123
|
+
assert.deepEqual(result.assertions, schema.assertions)
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
test('creates values from the JSON schema string', ({ assert }) => {
|
|
127
|
+
const schema: IRequestLog = {
|
|
128
|
+
kind: RequestLogKind,
|
|
129
|
+
request: {
|
|
130
|
+
startTime: 1234,
|
|
131
|
+
endTime: 5678,
|
|
132
|
+
url: 'https://dot.com',
|
|
133
|
+
},
|
|
134
|
+
response: {
|
|
135
|
+
loadingTime: 1,
|
|
136
|
+
status: 200,
|
|
137
|
+
},
|
|
138
|
+
assertions: [
|
|
139
|
+
{
|
|
140
|
+
description: 't1',
|
|
141
|
+
ok: true,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
}
|
|
145
|
+
const result = new RequestLog(JSON.stringify(schema))
|
|
146
|
+
assert.equal(result.kind, RequestLogKind)
|
|
147
|
+
assert.instanceOf(result.request, SentRequest)
|
|
148
|
+
assert.equal(result.request!.url, 'https://dot.com')
|
|
149
|
+
assert.deepEqual(result.assertions, schema.assertions)
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
test.group('Models > RequestLog > toJSON()', (group) => {
|
|
154
|
+
let schema: IRequestLog
|
|
155
|
+
let instance: RequestLog
|
|
156
|
+
group.each.setup(() => {
|
|
157
|
+
// Constructing with full objects to ensure instances are created for toJSON
|
|
158
|
+
instance = new RequestLog({
|
|
159
|
+
kind: RequestLogKind,
|
|
160
|
+
request: new SentRequest({ startTime: 1234, endTime: 5678, url: 'https://dot.com' }).toJSON(),
|
|
161
|
+
response: new Response({ loadingTime: 1, status: 200 }).toJSON(),
|
|
162
|
+
redirects: [
|
|
163
|
+
new ResponseRedirect({
|
|
164
|
+
startTime: 1234,
|
|
165
|
+
endTime: 5678,
|
|
166
|
+
url: 'https://dot.com',
|
|
167
|
+
response: new Response({ status: 200, loadingTime: 0 }).toJSON(),
|
|
168
|
+
kind: HttpResponseRedirectKind,
|
|
169
|
+
}).toJSON(),
|
|
170
|
+
],
|
|
171
|
+
size: { request: 123, response: 456 },
|
|
172
|
+
assertions: [{ description: 't1', ok: true }],
|
|
173
|
+
})
|
|
174
|
+
// schema is what we expect after toJSON()
|
|
175
|
+
schema = instance.toJSON()
|
|
176
|
+
})
|
|
177
|
+
|
|
178
|
+
test('serializes the kind', ({ assert }) => {
|
|
179
|
+
const result = instance.toJSON()
|
|
180
|
+
assert.equal(result.kind, RequestLogKind)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
test('serializes the request', ({ assert }) => {
|
|
184
|
+
const result = instance.toJSON()
|
|
185
|
+
assert.deepEqual(result.request, schema.request)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
test('does not serialize the request when missing', ({ assert }) => {
|
|
189
|
+
delete instance.request
|
|
190
|
+
const result = instance.toJSON()
|
|
191
|
+
assert.isUndefined(result.request)
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
test('serializes the size', ({ assert }) => {
|
|
195
|
+
const result = instance.toJSON()
|
|
196
|
+
assert.deepEqual(result.size, schema.size)
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
test('does not serialize the size when missing', ({ assert }) => {
|
|
200
|
+
delete instance.size
|
|
201
|
+
const result = instance.toJSON()
|
|
202
|
+
assert.isUndefined(result.size)
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
test('serializes the response', ({ assert }) => {
|
|
206
|
+
const result = instance.toJSON()
|
|
207
|
+
assert.deepEqual(result.response, schema.response)
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
test('does not serialize the response when missing', ({ assert }) => {
|
|
211
|
+
delete instance.response
|
|
212
|
+
const result = instance.toJSON()
|
|
213
|
+
assert.isUndefined(result.response)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
test('serializes the redirects', ({ assert }) => {
|
|
217
|
+
const result = instance.toJSON()
|
|
218
|
+
assert.deepEqual(result.redirects, schema.redirects)
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
test('does not serialize the redirects when missing', ({ assert }) => {
|
|
222
|
+
delete instance.redirects
|
|
223
|
+
const result = instance.toJSON()
|
|
224
|
+
assert.isUndefined(result.redirects)
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
test('serializes the assertions', ({ assert }) => {
|
|
228
|
+
const result = instance.toJSON()
|
|
229
|
+
assert.deepEqual(result.assertions, schema.assertions)
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
test('does not serialize the assertions when missing', ({ assert }) => {
|
|
233
|
+
delete instance.assertions
|
|
234
|
+
const result = instance.toJSON()
|
|
235
|
+
assert.isUndefined(result.assertions)
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
test.group('Models > RequestLog > addRedirect()', (group) => {
|
|
240
|
+
let instance: RequestLog
|
|
241
|
+
let redirectSchema: IResponseRedirect // Use IResponseRedirect for input
|
|
242
|
+
group.each.setup(() => {
|
|
243
|
+
instance = new RequestLog()
|
|
244
|
+
redirectSchema = {
|
|
245
|
+
// This is the input to addRedirect
|
|
246
|
+
startTime: 1234,
|
|
247
|
+
endTime: 5678,
|
|
248
|
+
url: 'https://dot.com',
|
|
249
|
+
response: { status: 200 }, // This will be converted to a Response instance
|
|
250
|
+
kind: HttpResponseRedirectKind,
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
|
|
254
|
+
test('adds a redirect and initializes the list', ({ assert }) => {
|
|
255
|
+
instance.addRedirect(redirectSchema)
|
|
256
|
+
assert.isArray(instance.redirects)
|
|
257
|
+
assert.lengthOf(instance.redirects!, 1)
|
|
258
|
+
assert.instanceOf(instance.redirects![0], ResponseRedirect)
|
|
259
|
+
})
|
|
260
|
+
|
|
261
|
+
test('returns the created redirect', ({ assert }) => {
|
|
262
|
+
const result = instance.addRedirect(redirectSchema)
|
|
263
|
+
assert.instanceOf(result, ResponseRedirect)
|
|
264
|
+
assert.isTrue(result === instance.redirects![0])
|
|
265
|
+
assert.equal(result.url, 'https://dot.com')
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
test('adds a redirect to already initialized list', ({ assert }) => {
|
|
269
|
+
instance.addRedirect(redirectSchema)
|
|
270
|
+
instance.addRedirect(redirectSchema)
|
|
271
|
+
assert.lengthOf(instance.redirects!, 2)
|
|
272
|
+
})
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
test.group('Models > RequestLog > addLegacyRedirect()', (group) => {
|
|
276
|
+
let instance: RequestLog
|
|
277
|
+
let legacyRedirectSchema: LegacyRedirect
|
|
278
|
+
group.each.setup(() => {
|
|
279
|
+
instance = new RequestLog()
|
|
280
|
+
legacyRedirectSchema = {
|
|
281
|
+
startTime: 1234,
|
|
282
|
+
endTime: 5678,
|
|
283
|
+
url: 'https://dot.com',
|
|
284
|
+
response: {
|
|
285
|
+
status: 200,
|
|
286
|
+
},
|
|
287
|
+
}
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
test('adds a redirect and initializes the list', async ({ assert }) => {
|
|
291
|
+
await instance.addLegacyRedirect(legacyRedirectSchema)
|
|
292
|
+
assert.isArray(instance.redirects)
|
|
293
|
+
assert.lengthOf(instance.redirects!, 1)
|
|
294
|
+
assert.instanceOf(instance.redirects![0], ResponseRedirect)
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
test('returns the created redirect', async ({ assert }) => {
|
|
298
|
+
const result = await instance.addLegacyRedirect(legacyRedirectSchema)
|
|
299
|
+
assert.instanceOf(result, ResponseRedirect)
|
|
300
|
+
assert.equal(result.url, 'https://dot.com')
|
|
301
|
+
})
|
|
302
|
+
|
|
303
|
+
test('adds a redirect to already initialized list', async ({ assert }) => {
|
|
304
|
+
await instance.addLegacyRedirect(legacyRedirectSchema)
|
|
305
|
+
await instance.addLegacyRedirect(legacyRedirectSchema)
|
|
306
|
+
assert.lengthOf(instance.redirects!, 2)
|
|
307
|
+
})
|
|
308
|
+
})
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { test } from '@japa/runner'
|
|
2
|
+
import { RequestTime, IRequestTime, Kind as RequestTimeKind } from '../../../src/models/RequestTime.js'
|
|
3
|
+
|
|
4
|
+
test.group('Models > RequestTime > constructor()', (group) => {
|
|
5
|
+
let schema: IRequestTime
|
|
6
|
+
group.each.setup(() => {
|
|
7
|
+
schema = {
|
|
8
|
+
kind: RequestTimeKind,
|
|
9
|
+
blocked: 1,
|
|
10
|
+
connect: 2,
|
|
11
|
+
dns: 3,
|
|
12
|
+
receive: 4,
|
|
13
|
+
send: 5,
|
|
14
|
+
wait: 6,
|
|
15
|
+
ssl: 7,
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
test('creates default values', ({ assert }) => {
|
|
20
|
+
const result = new RequestTime()
|
|
21
|
+
assert.equal(result.kind, RequestTimeKind)
|
|
22
|
+
assert.equal(result.connect, -1)
|
|
23
|
+
assert.equal(result.receive, -1)
|
|
24
|
+
assert.equal(result.send, -1)
|
|
25
|
+
assert.equal(result.wait, -1)
|
|
26
|
+
assert.equal(result.blocked, -1)
|
|
27
|
+
assert.equal(result.dns, -1)
|
|
28
|
+
assert.equal(result.ssl, -1)
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
test('creates the values from the schema', ({ assert }) => {
|
|
32
|
+
const result = new RequestTime(schema)
|
|
33
|
+
assert.equal(result.kind, RequestTimeKind)
|
|
34
|
+
assert.equal(result.connect, schema.connect)
|
|
35
|
+
assert.equal(result.receive, schema.receive)
|
|
36
|
+
assert.equal(result.send, schema.send)
|
|
37
|
+
assert.equal(result.wait, schema.wait)
|
|
38
|
+
assert.equal(result.blocked, schema.blocked)
|
|
39
|
+
assert.equal(result.dns, schema.dns)
|
|
40
|
+
assert.equal(result.ssl, schema.ssl)
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('creates the values from the JSON schema string', ({ assert }) => {
|
|
44
|
+
const result = new RequestTime(JSON.stringify(schema))
|
|
45
|
+
assert.equal(result.kind, RequestTimeKind)
|
|
46
|
+
assert.equal(result.connect, schema.connect)
|
|
47
|
+
assert.equal(result.receive, schema.receive)
|
|
48
|
+
assert.equal(result.send, schema.send)
|
|
49
|
+
assert.equal(result.wait, schema.wait)
|
|
50
|
+
assert.equal(result.blocked, schema.blocked)
|
|
51
|
+
assert.equal(result.dns, schema.dns)
|
|
52
|
+
assert.equal(result.ssl, schema.ssl)
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test.group('Models > RequestTime > toJSON()', (group) => {
|
|
57
|
+
let schema: IRequestTime
|
|
58
|
+
let instance: RequestTime
|
|
59
|
+
group.each.setup(() => {
|
|
60
|
+
schema = {
|
|
61
|
+
kind: RequestTimeKind,
|
|
62
|
+
blocked: 1,
|
|
63
|
+
connect: 2,
|
|
64
|
+
dns: 3,
|
|
65
|
+
receive: 4,
|
|
66
|
+
send: 5,
|
|
67
|
+
wait: 6,
|
|
68
|
+
ssl: 7,
|
|
69
|
+
}
|
|
70
|
+
instance = new RequestTime(schema)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('serializes the kind', ({ assert }) => {
|
|
74
|
+
const result = instance.toJSON()
|
|
75
|
+
assert.equal(result.kind, RequestTimeKind)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test('serializes the blocked', ({ assert }) => {
|
|
79
|
+
const result = instance.toJSON()
|
|
80
|
+
assert.equal(result.blocked, schema.blocked)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('serializes the connect', ({ assert }) => {
|
|
84
|
+
const result = instance.toJSON()
|
|
85
|
+
assert.equal(result.connect, schema.connect)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
test('serializes the dns', ({ assert }) => {
|
|
89
|
+
const result = instance.toJSON()
|
|
90
|
+
assert.equal(result.dns, schema.dns)
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
test('serializes the receive', ({ assert }) => {
|
|
94
|
+
const result = instance.toJSON()
|
|
95
|
+
assert.equal(result.receive, schema.receive)
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
test('serializes the send', ({ assert }) => {
|
|
99
|
+
const result = instance.toJSON()
|
|
100
|
+
assert.equal(result.send, schema.send)
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
test('serializes the wait', ({ assert }) => {
|
|
104
|
+
const result = instance.toJSON()
|
|
105
|
+
assert.equal(result.wait, schema.wait)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('serializes the ssl', ({ assert }) => {
|
|
109
|
+
const result = instance.toJSON()
|
|
110
|
+
assert.equal(result.ssl, schema.ssl)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
test('does not serialize the ssl when missing', ({ assert }) => {
|
|
114
|
+
delete instance.ssl
|
|
115
|
+
const result = instance.toJSON()
|
|
116
|
+
assert.isUndefined(result.ssl)
|
|
117
|
+
})
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
test.group('Models > RequestTime > total()', (group) => {
|
|
121
|
+
let instance: RequestTime
|
|
122
|
+
group.each.setup(() => {
|
|
123
|
+
instance = new RequestTime({
|
|
124
|
+
blocked: 1,
|
|
125
|
+
connect: 2,
|
|
126
|
+
dns: 3,
|
|
127
|
+
receive: 4,
|
|
128
|
+
send: 5,
|
|
129
|
+
wait: 6,
|
|
130
|
+
ssl: 7,
|
|
131
|
+
})
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
test('returns the sum of all values', ({ assert }) => {
|
|
135
|
+
const result = instance.total()
|
|
136
|
+
assert.equal(result, 28)
|
|
137
|
+
})
|
|
138
|
+
})
|