@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.
Files changed (96) hide show
  1. package/RELEASE.md +163 -0
  2. package/RELEASE_SETUP.md +235 -0
  3. package/build/src/events/authorization/AuthorizationEvents.d.ts +1 -1
  4. package/build/src/events/authorization/AuthorizationEvents.d.ts.map +1 -1
  5. package/build/src/events/authorization/AuthorizationEvents.js +1 -1
  6. package/build/src/events/authorization/AuthorizationEvents.js.map +1 -1
  7. package/build/src/events/cookies/CookieEvents.d.ts +1 -1
  8. package/build/src/events/cookies/CookieEvents.d.ts.map +1 -1
  9. package/build/src/events/cookies/CookieEvents.js +1 -1
  10. package/build/src/events/cookies/CookieEvents.js.map +1 -1
  11. package/build/src/modeling/DomainImpactAnalysis.d.ts +22 -119
  12. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  13. package/build/src/modeling/DomainImpactAnalysis.js +49 -155
  14. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  15. package/build/src/modeling/DomainValidation.d.ts +8 -0
  16. package/build/src/modeling/DomainValidation.d.ts.map +1 -0
  17. package/build/src/modeling/DomainValidation.js +99 -0
  18. package/build/src/modeling/DomainValidation.js.map +1 -0
  19. package/build/src/modeling/types.d.ts +70 -0
  20. package/build/src/modeling/types.d.ts.map +1 -1
  21. package/build/src/modeling/types.js.map +1 -1
  22. package/build/src/modeling/validation/rules.d.ts +2 -3
  23. package/build/src/modeling/validation/rules.d.ts.map +1 -1
  24. package/build/src/modeling/validation/rules.js.map +1 -1
  25. package/build/src/modeling/validation/semantic_validation.d.ts +31 -0
  26. package/build/src/modeling/validation/semantic_validation.d.ts.map +1 -0
  27. package/build/src/modeling/validation/semantic_validation.js +126 -0
  28. package/build/src/modeling/validation/semantic_validation.js.map +1 -0
  29. package/build/tsconfig.tsbuildinfo +1 -1
  30. package/data/models/example-generator-api.json +6 -6
  31. package/noop.ts +3 -0
  32. package/package.json +9 -4
  33. package/src/events/authorization/AuthorizationEvents.ts +1 -1
  34. package/src/events/cookies/CookieEvents.ts +1 -1
  35. package/src/modeling/DomainImpactAnalysis.ts +54 -239
  36. package/src/modeling/DomainValidation.ts +105 -0
  37. package/src/modeling/types.ts +86 -0
  38. package/src/modeling/validation/rules.ts +2 -4
  39. package/src/modeling/validation/semantic_validation.ts +145 -0
  40. package/tests/unit/events/EventsTestHelpers.ts +16 -0
  41. package/tests/unit/events/amf.spec.ts +151 -0
  42. package/tests/unit/events/authorization.spec.ts +150 -0
  43. package/tests/unit/events/cookie.spec.ts +274 -0
  44. package/tests/unit/events/encryption.spec.ts +108 -0
  45. package/tests/unit/events/events_polyfills.ts +77 -0
  46. package/tests/unit/events/process.spec.ts +120 -0
  47. package/tests/unit/events/reporting.spec.ts +82 -0
  48. package/tests/unit/events/telemetry.spec.ts +224 -0
  49. package/tests/unit/events/transport.spec.ts +139 -0
  50. package/tests/unit/modeling/domain_impact_analysis.spec.ts +0 -110
  51. package/tests/unit/modeling/domain_validation.spec.ts +94 -0
  52. package/tests/unit/modeling/validation/semantic_validation.spec.ts +91 -0
  53. package/tests/unit/models/environment.spec.ts +574 -0
  54. package/tests/unit/models/error_response.spec.ts +183 -0
  55. package/tests/unit/models/headers_array.spec.ts +86 -0
  56. package/tests/unit/models/http-actions/assertion/equal_assertion.spec.ts +103 -0
  57. package/tests/unit/models/http-actions/assertion/greater_than_assertion.spec.ts +91 -0
  58. package/tests/unit/models/http-actions/assertion/includes_assertion.spec.ts +71 -0
  59. package/tests/unit/models/http-actions/assertion/less_than_assertion.spec.ts +91 -0
  60. package/tests/unit/models/http-actions/assertion/matches_assertion.spec.ts +71 -0
  61. package/tests/unit/models/http-actions/assertion/matches_schema_assertion.spec.ts +117 -0
  62. package/tests/unit/models/http-actions/assertion/not_equal_assertion.spec.ts +103 -0
  63. package/tests/unit/models/http-actions/assertion/not_includes_assertion.spec.ts +71 -0
  64. package/tests/unit/models/http-actions/assertion/not_ok_assertion.spec.ts +47 -0
  65. package/tests/unit/models/http-actions/assertion/not_to_be_assertion.spec.ts +72 -0
  66. package/tests/unit/models/http-actions/assertion/ok_assertion.spec.ts +44 -0
  67. package/tests/unit/models/http-actions/assertion/to_be_assertion.spec.ts +71 -0
  68. package/tests/unit/models/http-actions/transformation/as_lower_case_step.spec.ts +47 -0
  69. package/tests/unit/models/http-actions/transformation/as_number_step.spec.ts +47 -0
  70. package/tests/unit/models/http-actions/transformation/as_upper_case_step.spec.ts +47 -0
  71. package/tests/unit/models/http-actions/transformation/round_step.spec.ts +69 -0
  72. package/tests/unit/models/http-actions/transformation/substring_step.spec.ts +85 -0
  73. package/tests/unit/models/http-actions/transformation/trim_step.spec.ts +44 -0
  74. package/tests/unit/models/http_cookie.spec.ts +516 -0
  75. package/tests/unit/models/http_history.spec.ts +443 -0
  76. package/tests/unit/models/project_folder.spec.ts +926 -0
  77. package/tests/unit/models/project_item.spec.ts +137 -0
  78. package/tests/unit/models/project_request.spec.ts +1047 -0
  79. package/tests/unit/models/project_schema.spec.ts +236 -0
  80. package/tests/unit/models/property.spec.ts +625 -0
  81. package/tests/unit/models/provider.spec.ts +102 -0
  82. package/tests/unit/models/request.spec.ts +1206 -0
  83. package/tests/unit/models/request_log.spec.ts +308 -0
  84. package/tests/unit/models/request_time.spec.ts +138 -0
  85. package/tests/unit/models/response_redirect.spec.ts +303 -0
  86. package/tests/unit/models/sent_request.spec.ts +206 -0
  87. package/tests/unit/models/server.spec.ts +195 -0
  88. package/tests/unit/models/thing.spec.ts +154 -0
  89. package/build/oauth-popup.html +0 -33
  90. /package/tests/unit/models/{Certificate.spec.ts → certificate.spec.ts} +0 -0
  91. /package/tests/unit/models/{HostRule.spec.ts → host_rule.spec.ts} +0 -0
  92. /package/tests/unit/models/{HttpProject.spec.ts → http_project.spec.ts} +0 -0
  93. /package/tests/unit/models/{HttpRequest.spec.ts → http_request.spec.ts} +0 -0
  94. /package/tests/unit/models/{HttpResponse.spec.ts → http_response.spec.ts} +0 -0
  95. /package/tests/unit/models/{License.spec.ts → license.spec.ts} +0 -0
  96. /package/tests/unit/models/{Response.spec.ts → response.spec.ts} +0 -0
@@ -0,0 +1,516 @@
1
+ import { test } from '@japa/runner'
2
+ import { HttpCookie, IHttpCookie } from '../../../src/models/HttpCookie.js'
3
+ import { ARCCookie as LegacyARCCookie } from '../../../src/models/legacy/models/Cookies.js'
4
+
5
+ test.group('HttpCookie.fromLegacy()', (group) => {
6
+ let schema: LegacyARCCookie
7
+
8
+ group.each.setup(() => {
9
+ schema = {
10
+ name: 'a',
11
+ value: 'b',
12
+ domain: 'c',
13
+ path: 'd',
14
+ }
15
+ })
16
+
17
+ test('sets the name', ({ assert }) => {
18
+ const result = HttpCookie.fromLegacy(schema)
19
+ assert.equal(result.name, schema.name)
20
+ })
21
+
22
+ test('sets the value', ({ assert }) => {
23
+ const result = HttpCookie.fromLegacy(schema)
24
+ assert.equal(result.value, schema.value)
25
+ })
26
+
27
+ test('sets the value when missing', ({ assert }) => {
28
+ delete schema.value
29
+ const result = HttpCookie.fromLegacy(schema)
30
+ assert.equal(result.value, '')
31
+ })
32
+
33
+ test('sets the domain', ({ assert }) => {
34
+ const result = HttpCookie.fromLegacy(schema)
35
+ assert.equal(result.domain, schema.domain)
36
+ })
37
+
38
+ test('does not set the domain when missing', ({ assert }) => {
39
+ // @ts-expect-error Used in testing
40
+ delete schema.domain
41
+ const result = HttpCookie.fromLegacy(schema)
42
+ assert.isUndefined(result.domain)
43
+ })
44
+
45
+ test('sets the path', ({ assert }) => {
46
+ const result = HttpCookie.fromLegacy(schema)
47
+ assert.equal(result.path, schema.path)
48
+ })
49
+
50
+ test('does not set the path when missing', ({ assert }) => {
51
+ // @ts-expect-error Used in testing
52
+ delete schema.path
53
+ const result = HttpCookie.fromLegacy(schema)
54
+ assert.isUndefined(result.path)
55
+ })
56
+
57
+ test('sets the expirationDate', ({ assert }) => {
58
+ schema.expires = 123456
59
+ const result = HttpCookie.fromLegacy(schema)
60
+ assert.equal(result.expirationDate, schema.expires)
61
+ })
62
+
63
+ test('does not set the expirationDate when missing', ({ assert }) => {
64
+ const result = HttpCookie.fromLegacy(schema)
65
+ assert.isUndefined(result.expirationDate)
66
+ })
67
+
68
+ test('sets the hostOnly', ({ assert }) => {
69
+ schema.hostOnly = false
70
+ const result = HttpCookie.fromLegacy(schema)
71
+ assert.isFalse(result.hostOnly)
72
+ })
73
+
74
+ test('does not set the hostOnly when missing', ({ assert }) => {
75
+ const result = HttpCookie.fromLegacy(schema)
76
+ assert.isUndefined(result.hostOnly)
77
+ })
78
+
79
+ test('sets the httpOnly', ({ assert }) => {
80
+ schema.httpOnly = false
81
+ const result = HttpCookie.fromLegacy(schema)
82
+ assert.isFalse(result.httpOnly)
83
+ })
84
+
85
+ test('does not set the httpOnly when missing', ({ assert }) => {
86
+ const result = HttpCookie.fromLegacy(schema)
87
+ assert.isUndefined(result.httpOnly)
88
+ })
89
+
90
+ test('sets the secure', ({ assert }) => {
91
+ schema.secure = false
92
+ const result = HttpCookie.fromLegacy(schema)
93
+ assert.isFalse(result.secure)
94
+ })
95
+
96
+ test('does not set the secure when missing', ({ assert }) => {
97
+ const result = HttpCookie.fromLegacy(schema)
98
+ assert.isUndefined(result.secure)
99
+ })
100
+
101
+ test('sets the session', ({ assert }) => {
102
+ schema.session = true
103
+ const result = HttpCookie.fromLegacy(schema)
104
+ assert.isTrue(result.session)
105
+ })
106
+
107
+ test('set the session when not expires', ({ assert }) => {
108
+ const result = HttpCookie.fromLegacy(schema)
109
+ assert.isTrue(result.session)
110
+ })
111
+
112
+ test('set the session when expires', ({ assert }) => {
113
+ const result = HttpCookie.fromLegacy({ ...schema, expires: 1234 })
114
+ assert.isFalse(result.session)
115
+ })
116
+ })
117
+
118
+ test.group('HttpCookie constructor()', (group) => {
119
+ const invalid = `test${String.fromCharCode(0x1f)}`
120
+ let schema: IHttpCookie
121
+
122
+ group.each.setup(() => {
123
+ schema = {
124
+ name: 'a',
125
+ value: 'b',
126
+ sameSite: 'strict',
127
+ }
128
+ })
129
+
130
+ test('sets the name', ({ assert }) => {
131
+ const result = new HttpCookie(schema)
132
+ assert.equal(result.name, schema.name)
133
+ })
134
+
135
+ test('sets the default name when missing', ({ assert }) => {
136
+ // @ts-expect-error Used in testing
137
+ delete schema.name
138
+ const result = new HttpCookie(schema)
139
+ assert.equal(result.name, '')
140
+ })
141
+
142
+ test('sets the value', ({ assert }) => {
143
+ const result = new HttpCookie(schema)
144
+ assert.equal(result.value, schema.value)
145
+ })
146
+
147
+ test('sets the default value when missing', ({ assert }) => {
148
+ // @ts-expect-error Used in testing
149
+ delete schema.value
150
+ const result = new HttpCookie(schema)
151
+ assert.equal(result.value, '')
152
+ })
153
+
154
+ test('sets the domain', ({ assert }) => {
155
+ schema.domain = 'dot.com'
156
+ const result = new HttpCookie(schema)
157
+ assert.equal(result.domain, schema.domain)
158
+ })
159
+
160
+ test('does not set the domain when missing', ({ assert }) => {
161
+ const result = new HttpCookie(schema)
162
+ assert.isUndefined(result.domain)
163
+ })
164
+
165
+ test('sets the path', ({ assert }) => {
166
+ schema.domain = '/abc'
167
+ const result = new HttpCookie(schema)
168
+ assert.equal(result.path, schema.path)
169
+ })
170
+
171
+ test('does not set the path when missing', ({ assert }) => {
172
+ const result = new HttpCookie(schema)
173
+ assert.isUndefined(result.path)
174
+ })
175
+
176
+ test('sets the expirationDate', ({ assert }) => {
177
+ schema.expirationDate = 123456
178
+ const result = new HttpCookie(schema)
179
+ assert.equal(result.expirationDate, schema.expirationDate)
180
+ })
181
+
182
+ test('does not set the expirationDate when missing', ({ assert }) => {
183
+ const result = new HttpCookie(schema)
184
+ assert.isUndefined(result.expirationDate)
185
+ })
186
+
187
+ test('sets the expirationDate from string number', ({ assert }) => {
188
+ const cookie = new HttpCookie()
189
+ cookie.expirationDate = '123456'
190
+ assert.equal(cookie.expirationDate, 123456)
191
+ })
192
+
193
+ test('sets the hostOnly', ({ assert }) => {
194
+ schema.hostOnly = false
195
+ const result = new HttpCookie(schema)
196
+ assert.isFalse(result.hostOnly)
197
+ })
198
+
199
+ test('does not set the hostOnly when missing', ({ assert }) => {
200
+ const result = new HttpCookie(schema)
201
+ assert.isUndefined(result.hostOnly)
202
+ })
203
+
204
+ test('sets the httpOnly', ({ assert }) => {
205
+ schema.httpOnly = false
206
+ const result = new HttpCookie(schema)
207
+ assert.isFalse(result.httpOnly)
208
+ })
209
+
210
+ test('does not set the httpOnly when missing', ({ assert }) => {
211
+ const result = new HttpCookie(schema)
212
+ assert.isUndefined(result.httpOnly)
213
+ })
214
+
215
+ test('sets the secure', ({ assert }) => {
216
+ schema.secure = false
217
+ const result = new HttpCookie(schema)
218
+ assert.isFalse(result.secure)
219
+ })
220
+
221
+ test('does not set the secure when missing', ({ assert }) => {
222
+ const result = new HttpCookie(schema)
223
+ assert.isUndefined(result.secure)
224
+ })
225
+
226
+ test('sets the session', ({ assert }) => {
227
+ schema.session = true
228
+ const result = new HttpCookie(schema)
229
+ assert.isTrue(result.session)
230
+ })
231
+
232
+ test('sets the default session', ({ assert }) => {
233
+ const result = new HttpCookie(schema)
234
+ assert.isTrue(result.session)
235
+ })
236
+
237
+ test('creates the default values when no argument', ({ assert }) => {
238
+ const result = new HttpCookie()
239
+ assert.equal(result.name, '')
240
+ assert.equal(result.value, '')
241
+ assert.equal(result.sameSite, 'unspecified')
242
+ assert.isUndefined(result.domain)
243
+ assert.isUndefined(result.path)
244
+ assert.isUndefined(result.expirationDate)
245
+ assert.isUndefined(result.hostOnly)
246
+ assert.isUndefined(result.httpOnly)
247
+ assert.isUndefined(result.secure)
248
+ assert.isTrue(result.session)
249
+ })
250
+
251
+ test('creates the cookie from the schema', ({ assert }) => {
252
+ const result = new HttpCookie(JSON.stringify(schema))
253
+ assert.equal(result.name, schema.name)
254
+ assert.equal(result.value, schema.value)
255
+ assert.equal(result.sameSite, schema.sameSite)
256
+ assert.isUndefined(result.domain)
257
+ assert.isUndefined(result.path)
258
+ assert.isUndefined(result.expirationDate)
259
+ assert.isUndefined(result.hostOnly)
260
+ assert.isUndefined(result.httpOnly)
261
+ assert.isUndefined(result.secure)
262
+ assert.isTrue(result.session)
263
+ })
264
+
265
+ test('throws an error for invalid name', ({ assert }) => {
266
+ assert.throws(() => {
267
+ new HttpCookie({ name: invalid, value: '', sameSite: 'lax' })
268
+ })
269
+ })
270
+
271
+ test('throws an error for invalid value', ({ assert }) => {
272
+ assert.throws(() => {
273
+ new HttpCookie({ name: 'test', value: invalid, sameSite: 'lax' })
274
+ })
275
+ })
276
+
277
+ test('throws an error for invalid path', ({ assert }) => {
278
+ assert.throws(() => {
279
+ new HttpCookie({ name: 'test', value: '', sameSite: 'lax', path: invalid })
280
+ })
281
+ })
282
+
283
+ test('throws an error for invalid domain', ({ assert }) => {
284
+ assert.throws(() => {
285
+ new HttpCookie({ name: 'test', value: '', sameSite: 'lax', domain: invalid })
286
+ })
287
+ })
288
+ })
289
+
290
+ test.group('HttpCookie #maxAge', () => {
291
+ test('sets the expirationDate', ({ assert }) => {
292
+ const instance = new HttpCookie()
293
+ instance.maxAge = 100
294
+ // @ts-expect-error Used in testing
295
+ assert.approximately(instance.expirationDate, Date.now() + 100000, 1000)
296
+ })
297
+
298
+ test('sets the cookie persistent', ({ assert }) => {
299
+ const instance = new HttpCookie()
300
+ instance.maxAge = 100
301
+ assert.isFalse(instance.session)
302
+ })
303
+
304
+ test('sets lowest possible expiration date', ({ assert }) => {
305
+ const instance = new HttpCookie()
306
+ instance.maxAge = -100
307
+ const compare = new Date(-8640000000000000).getTime()
308
+ assert.equal(instance.expirationDate, compare)
309
+ })
310
+
311
+ test('sets the expirationDate from the "max-age" property', ({ assert }) => {
312
+ const instance = new HttpCookie()
313
+ instance['max-age'] = 100
314
+ // @ts-expect-error Used in testing
315
+ assert.approximately(instance.expirationDate, Date.now() + 100000, 1000)
316
+ })
317
+
318
+ test('ignores non-numeric values', ({ assert }) => {
319
+ const instance = new HttpCookie()
320
+ // @ts-expect-error Used in testing
321
+ instance.maxAge = 'test'
322
+ assert.isUndefined(instance.expirationDate)
323
+ })
324
+
325
+ test('sets the expirationDate for maxAge 0', ({ assert }) => {
326
+ const instance = new HttpCookie()
327
+ instance.maxAge = 0
328
+ // @ts-expect-error Used in testing
329
+ assert.isBelow(instance.expirationDate, -1)
330
+ })
331
+
332
+ test('sets the expirationDate for maxAge -1', ({ assert }) => {
333
+ const instance = new HttpCookie()
334
+ instance.maxAge = -1
335
+ // @ts-expect-error Used in testing
336
+ assert.isBelow(instance.expirationDate, -1)
337
+ })
338
+
339
+ test('sets the expirationDate for maxAge 1', ({ assert }) => {
340
+ const instance = new HttpCookie()
341
+ instance.maxAge = 1
342
+ // @ts-expect-error Used in testing
343
+ assert.isAbove(instance.expirationDate, Date.now())
344
+ })
345
+ })
346
+
347
+ test.group('HttpCookie #expires', () => {
348
+ test('sets "expirationDate" from timestamp', ({ assert }) => {
349
+ const instance = new HttpCookie()
350
+ const now = Date.now()
351
+ instance.expires = now
352
+ assert.equal(instance.expirationDate, now)
353
+ })
354
+
355
+ test('sets expires from ISO string', ({ assert }) => {
356
+ const instance = new HttpCookie()
357
+ const now = new Date()
358
+ const time = now.getTime()
359
+ instance.expires = now.toISOString()
360
+ assert.equal(instance.expirationDate, time)
361
+ })
362
+ })
363
+
364
+ test.group('HttpCookie toJSON()', (group) => {
365
+ let schema: IHttpCookie
366
+ let instance: HttpCookie
367
+
368
+ group.each.setup(() => {
369
+ schema = {
370
+ name: 'a',
371
+ value: 'b',
372
+ sameSite: 'strict',
373
+ }
374
+ instance = new HttpCookie(schema)
375
+ })
376
+
377
+ test('serializes the name', ({ assert }) => {
378
+ const result = instance.toJSON()
379
+ assert.equal(result.name, schema.name)
380
+ })
381
+
382
+ test('serializes the value', ({ assert }) => {
383
+ const result = instance.toJSON()
384
+ assert.equal(result.value, schema.value)
385
+ })
386
+
387
+ test('serializes the sameSite', ({ assert }) => {
388
+ const result = instance.toJSON()
389
+ assert.equal(result.sameSite, schema.sameSite)
390
+ })
391
+
392
+ test('serializes the domain', ({ assert }) => {
393
+ instance.domain = 'dot.com'
394
+ const result = instance.toJSON()
395
+ assert.equal(result.domain, instance.domain)
396
+ })
397
+
398
+ test('serializes the expirationDate', ({ assert }) => {
399
+ instance.expirationDate = 1234
400
+ const result = instance.toJSON()
401
+ assert.equal(result.expirationDate, instance.expirationDate)
402
+ })
403
+
404
+ test('serializes the hostOnly', ({ assert }) => {
405
+ instance.hostOnly = false
406
+ const result = instance.toJSON()
407
+ assert.equal(result.hostOnly, instance.hostOnly)
408
+ })
409
+
410
+ test('serializes the httpOnly', ({ assert }) => {
411
+ instance.httpOnly = false
412
+ const result = instance.toJSON()
413
+ assert.equal(result.httpOnly, instance.httpOnly)
414
+ })
415
+
416
+ test('serializes the secure', ({ assert }) => {
417
+ instance.secure = false
418
+ const result = instance.toJSON()
419
+ assert.equal(result.secure, instance.secure)
420
+ })
421
+
422
+ test('serializes the session', ({ assert }) => {
423
+ instance.session = false
424
+ const result = instance.toJSON()
425
+ assert.equal(result.session, instance.session)
426
+ })
427
+
428
+ test('serializes the path', ({ assert }) => {
429
+ instance.path = '/abc'
430
+ const result = instance.toJSON()
431
+ assert.equal(result.path, instance.path)
432
+ })
433
+ })
434
+
435
+ test.group('HttpCookie toString()', (group) => {
436
+ let instance: HttpCookie
437
+
438
+ group.each.setup(() => {
439
+ instance = new HttpCookie({ name: 'test-name', value: 'test-value' })
440
+ })
441
+
442
+ test('returns cookie header string', ({ assert }) => {
443
+ const result = instance.toString()
444
+ assert.equal(result, 'test-name=test-value')
445
+ })
446
+ })
447
+
448
+ test.group('HttpCookie toHeader()', (group) => {
449
+ let instance: HttpCookie
450
+ const base = 'test-name=test-value'
451
+
452
+ group.each.setup(() => {
453
+ instance = new HttpCookie({ name: 'test-name', value: 'test-value' })
454
+ })
455
+
456
+ test('returns the basic cookie header string', ({ assert }) => {
457
+ const result = instance.toHeader()
458
+ assert.equal(result, base)
459
+ })
460
+
461
+ test('adds the path', ({ assert }) => {
462
+ instance.path = '/api'
463
+ const result = instance.toHeader()
464
+ assert.equal(result, `${base}; path=/api`)
465
+ })
466
+
467
+ test('adds the domain', ({ assert }) => {
468
+ instance.domain = 'api.com'
469
+ const result = instance.toHeader()
470
+ assert.equal(result, `${base}; domain=api.com`)
471
+ })
472
+
473
+ test('adds the httpOnly', ({ assert }) => {
474
+ instance.httpOnly = true
475
+ const result = instance.toHeader()
476
+ assert.equal(result, `${base}; httpOnly=true`)
477
+ })
478
+
479
+ test('adds the expires', ({ assert }) => {
480
+ const now = new Date()
481
+ const isoDate = now.toISOString()
482
+ const utcDate = now.toUTCString()
483
+ instance.expires = isoDate
484
+
485
+ const result = instance.toHeader()
486
+ assert.equal(result, `${base}; expires=${utcDate}`)
487
+ })
488
+
489
+ test('adds the secure', ({ assert }) => {
490
+ instance.secure = true
491
+
492
+ const result = instance.toHeader()
493
+ assert.equal(result, `${base}; Secure`)
494
+ })
495
+
496
+ test('adds the SameSite=Lax', ({ assert }) => {
497
+ instance.sameSite = 'lax'
498
+
499
+ const result = instance.toHeader()
500
+ assert.equal(result, `${base}; SameSite=Lax`)
501
+ })
502
+
503
+ test('adds the SameSite=None', ({ assert }) => {
504
+ instance.sameSite = 'no_restriction'
505
+
506
+ const result = instance.toHeader()
507
+ assert.equal(result, `${base}; SameSite=None`)
508
+ })
509
+
510
+ test('adds the SameSite=Strict', ({ assert }) => {
511
+ instance.sameSite = 'strict'
512
+
513
+ const result = instance.toHeader()
514
+ assert.equal(result, `${base}; SameSite=Strict; Secure`)
515
+ })
516
+ })