@api-client/core 0.18.40 → 0.18.46

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.
@@ -0,0 +1,449 @@
1
+ import { test } from '@japa/runner'
2
+ import sinon from 'sinon'
3
+ import { DataCatalog } from '../../../../src/mocking/lib/DataCatalog.js'
4
+ import { DataCatalogKind, DataCatalogVersionKind } from '../../../../src/models/kinds.js'
5
+ import type {
6
+ DataCatalogSchema,
7
+ DataCatalogSchemaWithVersion,
8
+ DataCatalogVersionInfo,
9
+ } from '../../../../src/models/DataCatalog.js'
10
+ import type { DataCatalogVersionSchema } from '../../../../src/models/DataCatalogVersion.js'
11
+
12
+ test.group('dataCatalog()', (group) => {
13
+ let catalog: DataCatalog
14
+
15
+ group.each.setup(() => {
16
+ catalog = new DataCatalog()
17
+ })
18
+
19
+ test('returns an object', ({ assert }) => {
20
+ const result = catalog.dataCatalog()
21
+ assert.typeOf(result, 'object')
22
+ })
23
+
24
+ test('has the {property} property of a type {type}')
25
+ .with([
26
+ { property: 'kind', type: 'string' },
27
+ { property: 'key', type: 'string' },
28
+ { property: 'name', type: 'string' },
29
+ { property: 'organization', type: 'string' },
30
+ { property: 'file', type: 'string' },
31
+ { property: 'scope', type: 'string' },
32
+ { property: 'description', type: 'string' },
33
+ { property: 'publishedBy', type: 'string' },
34
+ { property: 'publishedAt', type: 'number' },
35
+ { property: 'createdAt', type: 'number' },
36
+ { property: 'updatedAt', type: 'number' },
37
+ { property: 'tags', type: 'array' },
38
+ ])
39
+ .run(({ assert }, { property, type }) => {
40
+ const result = catalog.dataCatalog()
41
+ assert.typeOf(result[property as keyof DataCatalogSchema], type)
42
+ })
43
+
44
+ test('has the correct kind', ({ assert }) => {
45
+ const result = catalog.dataCatalog()
46
+ assert.equal(result.kind, DataCatalogKind)
47
+ })
48
+
49
+ test('scope is one of the valid values', ({ assert }) => {
50
+ const result = catalog.dataCatalog()
51
+ assert.include(['public', 'private', 'organization'], result.scope)
52
+ })
53
+
54
+ test('uses passed key', ({ assert }) => {
55
+ const result = catalog.dataCatalog({ key: 'custom-key' })
56
+ assert.equal(result.key, 'custom-key')
57
+ })
58
+
59
+ test('uses passed name', ({ assert }) => {
60
+ const result = catalog.dataCatalog({ name: 'Custom Catalog' })
61
+ assert.equal(result.name, 'Custom Catalog')
62
+ })
63
+
64
+ test('uses passed organization', ({ assert }) => {
65
+ const result = catalog.dataCatalog({ organization: 'org-123' })
66
+ assert.equal(result.organization, 'org-123')
67
+ })
68
+
69
+ test('uses passed file', ({ assert }) => {
70
+ const result = catalog.dataCatalog({ file: 'file-456' })
71
+ assert.equal(result.file, 'file-456')
72
+ })
73
+
74
+ test('uses passed scope', ({ assert }) => {
75
+ const result = catalog.dataCatalog({ scope: 'private' })
76
+ assert.equal(result.scope, 'private')
77
+ })
78
+
79
+ test('uses passed description', ({ assert }) => {
80
+ const result = catalog.dataCatalog({ description: 'Test description' })
81
+ assert.equal(result.description, 'Test description')
82
+ })
83
+
84
+ test('uses passed publishedBy', ({ assert }) => {
85
+ const result = catalog.dataCatalog({ publishedBy: 'user-789' })
86
+ assert.equal(result.publishedBy, 'user-789')
87
+ })
88
+
89
+ test('uses passed publishedAt', ({ assert }) => {
90
+ const timestamp = Date.now()
91
+ const result = catalog.dataCatalog({ publishedAt: timestamp })
92
+ assert.equal(result.publishedAt, timestamp)
93
+ })
94
+
95
+ test('uses passed createdAt', ({ assert }) => {
96
+ const timestamp = Date.now()
97
+ const result = catalog.dataCatalog({ createdAt: timestamp })
98
+ assert.equal(result.createdAt, timestamp)
99
+ })
100
+
101
+ test('uses passed updatedAt', ({ assert }) => {
102
+ const timestamp = Date.now()
103
+ const result = catalog.dataCatalog({ updatedAt: timestamp })
104
+ assert.equal(result.updatedAt, timestamp)
105
+ })
106
+
107
+ test('uses passed tags', ({ assert }) => {
108
+ const tags = ['tag1', 'tag2', 'tag3']
109
+ const result = catalog.dataCatalog({ tags })
110
+ assert.deepEqual(result.tags, tags)
111
+ })
112
+ })
113
+
114
+ test.group('dataCatalogs()', (group) => {
115
+ let catalog: DataCatalog
116
+
117
+ group.each.setup(() => {
118
+ catalog = new DataCatalog()
119
+ })
120
+
121
+ test('returns an array', ({ assert }) => {
122
+ const result = catalog.dataCatalogs()
123
+ assert.typeOf(result, 'array')
124
+ })
125
+
126
+ test('list has default number of items', ({ assert }) => {
127
+ const result = catalog.dataCatalogs()
128
+ assert.lengthOf(result, 25)
129
+ })
130
+
131
+ test('returns requested number of items', ({ assert }) => {
132
+ const result = catalog.dataCatalogs(10)
133
+ assert.lengthOf(result, 10)
134
+ })
135
+
136
+ test('calls dataCatalog()', ({ assert }) => {
137
+ const spy = sinon.spy(catalog, 'dataCatalog')
138
+ catalog.dataCatalogs(5)
139
+ assert.equal(spy.callCount, 5)
140
+ })
141
+ })
142
+
143
+ test.group('dataCatalogVersion()', (group) => {
144
+ let catalog: DataCatalog
145
+
146
+ group.each.setup(() => {
147
+ catalog = new DataCatalog()
148
+ })
149
+
150
+ test('returns an object', ({ assert }) => {
151
+ const result = catalog.dataCatalogVersion()
152
+ assert.typeOf(result, 'object')
153
+ })
154
+
155
+ test('has the {property} property of a type {type}')
156
+ .with([
157
+ { property: 'kind', type: 'string' },
158
+ { property: 'key', type: 'string' },
159
+ { property: 'catalogKey', type: 'string' },
160
+ { property: 'scope', type: 'string' },
161
+ { property: 'lifecycle', type: 'string' },
162
+ { property: 'version', type: 'string' },
163
+ { property: 'publishedBy', type: 'string' },
164
+ { property: 'createdAt', type: 'number' },
165
+ { property: 'updatedAt', type: 'number' },
166
+ { property: 'changelog', type: 'string' },
167
+ ])
168
+ .run(({ assert }, { property, type }) => {
169
+ const result = catalog.dataCatalogVersion()
170
+ assert.typeOf(result[property as keyof DataCatalogVersionSchema], type)
171
+ })
172
+
173
+ test('has the correct kind', ({ assert }) => {
174
+ const result = catalog.dataCatalogVersion()
175
+ assert.equal(result.kind, DataCatalogVersionKind)
176
+ })
177
+
178
+ test('scope is one of the valid values', ({ assert }) => {
179
+ const result = catalog.dataCatalogVersion()
180
+ assert.include(['public', 'private', 'organization'], result.scope)
181
+ })
182
+
183
+ test('lifecycle is one of the valid values', ({ assert }) => {
184
+ const result = catalog.dataCatalogVersion()
185
+ assert.include(['stable', 'beta', 'dev'], result.lifecycle)
186
+ })
187
+
188
+ test('version starts with v', ({ assert }) => {
189
+ const result = catalog.dataCatalogVersion()
190
+ assert.isTrue(result.version.startsWith('v'))
191
+ })
192
+
193
+ test('uses passed key', ({ assert }) => {
194
+ const result = catalog.dataCatalogVersion({ key: 'version-key' })
195
+ assert.equal(result.key, 'version-key')
196
+ })
197
+
198
+ test('uses passed catalogKey', ({ assert }) => {
199
+ const result = catalog.dataCatalogVersion({ catalogKey: 'catalog-123' })
200
+ assert.equal(result.catalogKey, 'catalog-123')
201
+ })
202
+
203
+ test('uses passed scope', ({ assert }) => {
204
+ const result = catalog.dataCatalogVersion({ scope: 'private' })
205
+ assert.equal(result.scope, 'private')
206
+ })
207
+
208
+ test('uses passed lifecycle', ({ assert }) => {
209
+ const result = catalog.dataCatalogVersion({ lifecycle: 'beta' })
210
+ assert.equal(result.lifecycle, 'beta')
211
+ })
212
+
213
+ test('uses passed version', ({ assert }) => {
214
+ const result = catalog.dataCatalogVersion({ version: 'v2.0.0' })
215
+ assert.equal(result.version, 'v2.0.0')
216
+ })
217
+
218
+ test('uses passed publishedBy', ({ assert }) => {
219
+ const result = catalog.dataCatalogVersion({ publishedBy: 'user-999' })
220
+ assert.equal(result.publishedBy, 'user-999')
221
+ })
222
+
223
+ test('uses passed createdAt', ({ assert }) => {
224
+ const timestamp = Date.now()
225
+ const result = catalog.dataCatalogVersion({ createdAt: timestamp })
226
+ assert.equal(result.createdAt, timestamp)
227
+ })
228
+
229
+ test('uses passed updatedAt', ({ assert }) => {
230
+ const timestamp = Date.now()
231
+ const result = catalog.dataCatalogVersion({ updatedAt: timestamp })
232
+ assert.equal(result.updatedAt, timestamp)
233
+ })
234
+
235
+ test('uses passed changelog', ({ assert }) => {
236
+ const result = catalog.dataCatalogVersion({ changelog: 'Custom changelog' })
237
+ assert.equal(result.changelog, 'Custom changelog')
238
+ })
239
+ })
240
+
241
+ test.group('dataCatalogVersions()', (group) => {
242
+ let catalog: DataCatalog
243
+
244
+ group.each.setup(() => {
245
+ catalog = new DataCatalog()
246
+ })
247
+
248
+ test('returns an array', ({ assert }) => {
249
+ const result = catalog.dataCatalogVersions()
250
+ assert.typeOf(result, 'array')
251
+ })
252
+
253
+ test('list has default number of items', ({ assert }) => {
254
+ const result = catalog.dataCatalogVersions()
255
+ assert.lengthOf(result, 25)
256
+ })
257
+
258
+ test('returns requested number of items', ({ assert }) => {
259
+ const result = catalog.dataCatalogVersions(7)
260
+ assert.lengthOf(result, 7)
261
+ })
262
+
263
+ test('calls dataCatalogVersion()', ({ assert }) => {
264
+ const spy = sinon.spy(catalog, 'dataCatalogVersion')
265
+ catalog.dataCatalogVersions(3)
266
+ assert.equal(spy.callCount, 3)
267
+ })
268
+ })
269
+
270
+ test.group('dataCatalogWithVersion()', (group) => {
271
+ let catalog: DataCatalog
272
+
273
+ group.each.setup(() => {
274
+ catalog = new DataCatalog()
275
+ })
276
+
277
+ test('returns an object', ({ assert }) => {
278
+ const result = catalog.dataCatalogWithVersion()
279
+ assert.typeOf(result, 'object')
280
+ })
281
+
282
+ test('has the {property} property of a type {type}')
283
+ .with([
284
+ { property: 'kind', type: 'string' },
285
+ { property: 'key', type: 'string' },
286
+ { property: 'name', type: 'string' },
287
+ { property: 'organization', type: 'string' },
288
+ { property: 'file', type: 'string' },
289
+ { property: 'scope', type: 'string' },
290
+ { property: 'description', type: 'string' },
291
+ { property: 'publishedBy', type: 'string' },
292
+ { property: 'publishedAt', type: 'number' },
293
+ { property: 'createdAt', type: 'number' },
294
+ { property: 'updatedAt', type: 'number' },
295
+ { property: 'tags', type: 'array' },
296
+ { property: 'versions', type: 'array' },
297
+ ])
298
+ .run(({ assert }, { property, type }) => {
299
+ const result = catalog.dataCatalogWithVersion()
300
+ assert.typeOf(result[property as keyof DataCatalogSchemaWithVersion], type)
301
+ })
302
+
303
+ test('has at least one version', ({ assert }) => {
304
+ const result = catalog.dataCatalogWithVersion()
305
+ assert.isAtLeast(result.versions.length, 1)
306
+ })
307
+
308
+ test('has at most 20 versions', ({ assert }) => {
309
+ const result = catalog.dataCatalogWithVersion()
310
+ assert.isAtMost(result.versions.length, 20)
311
+ })
312
+
313
+ test('each version has required properties', ({ assert }) => {
314
+ const result = catalog.dataCatalogWithVersion()
315
+ result.versions.forEach((version) => {
316
+ assert.typeOf(version.version, 'string')
317
+ assert.typeOf(version.lifecycle, 'string')
318
+ assert.include(['stable', 'beta', 'dev'], version.lifecycle)
319
+ })
320
+ })
321
+
322
+ test('versions follow semantic versioning pattern', ({ assert }) => {
323
+ const result = catalog.dataCatalogWithVersion()
324
+ result.versions.forEach((version) => {
325
+ assert.match(version.version, /^v\d+\.\d+\.\d+$/)
326
+ })
327
+ })
328
+
329
+ test('uses passed initialization values', ({ assert }) => {
330
+ const result = catalog.dataCatalogWithVersion({
331
+ key: 'custom-key',
332
+ name: 'Custom Name',
333
+ })
334
+ assert.equal(result.key, 'custom-key')
335
+ assert.equal(result.name, 'Custom Name')
336
+ assert.isArray(result.versions)
337
+ })
338
+ })
339
+
340
+ test.group('dataCatalogsWithVersion()', (group) => {
341
+ let catalog: DataCatalog
342
+
343
+ group.each.setup(() => {
344
+ catalog = new DataCatalog()
345
+ })
346
+
347
+ test('returns an array', ({ assert }) => {
348
+ const result = catalog.dataCatalogsWithVersion()
349
+ assert.typeOf(result, 'array')
350
+ })
351
+
352
+ test('list has default number of items', ({ assert }) => {
353
+ const result = catalog.dataCatalogsWithVersion()
354
+ assert.lengthOf(result, 3)
355
+ })
356
+
357
+ test('returns requested number of items', ({ assert }) => {
358
+ const result = catalog.dataCatalogsWithVersion(5)
359
+ assert.lengthOf(result, 5)
360
+ })
361
+
362
+ test('calls dataCatalogWithVersion()', ({ assert }) => {
363
+ const spy = sinon.spy(catalog, 'dataCatalogWithVersion')
364
+ catalog.dataCatalogsWithVersion(4)
365
+ assert.equal(spy.callCount, 4)
366
+ })
367
+
368
+ test('each item has versions array', ({ assert }) => {
369
+ const result = catalog.dataCatalogsWithVersion(2)
370
+ result.forEach((item) => {
371
+ assert.isArray(item.versions)
372
+ assert.isAtLeast(item.versions.length, 1)
373
+ })
374
+ })
375
+ })
376
+
377
+ test.group('versionInfo()', (group) => {
378
+ let catalog: DataCatalog
379
+
380
+ group.each.setup(() => {
381
+ catalog = new DataCatalog()
382
+ })
383
+
384
+ test('returns an object', ({ assert }) => {
385
+ const result = catalog.versionInfo()
386
+ assert.typeOf(result, 'object')
387
+ })
388
+
389
+ test('has the {property} property of a type {type}')
390
+ .with([
391
+ { property: 'key', type: 'string' },
392
+ { property: 'version', type: 'string' },
393
+ { property: 'published', type: 'number' },
394
+ ])
395
+ .run(({ assert }, { property, type }) => {
396
+ const result = catalog.versionInfo()
397
+ assert.typeOf(result[property as keyof DataCatalogVersionInfo], type)
398
+ })
399
+
400
+ test('version starts with v', ({ assert }) => {
401
+ const result = catalog.versionInfo()
402
+ assert.isTrue(result.version.startsWith('v'))
403
+ })
404
+
405
+ test('uses passed key', ({ assert }) => {
406
+ const result = catalog.versionInfo({ key: 'info-key' })
407
+ assert.equal(result.key, 'info-key')
408
+ })
409
+
410
+ test('uses passed version', ({ assert }) => {
411
+ const result = catalog.versionInfo({ version: 'v3.0.0' })
412
+ assert.equal(result.version, 'v3.0.0')
413
+ })
414
+
415
+ test('uses passed published timestamp', ({ assert }) => {
416
+ const timestamp = Date.now()
417
+ const result = catalog.versionInfo({ published: timestamp })
418
+ assert.equal(result.published, timestamp)
419
+ })
420
+ })
421
+
422
+ test.group('versionInfos()', (group) => {
423
+ let catalog: DataCatalog
424
+
425
+ group.each.setup(() => {
426
+ catalog = new DataCatalog()
427
+ })
428
+
429
+ test('returns an array', ({ assert }) => {
430
+ const result = catalog.versionInfos()
431
+ assert.typeOf(result, 'array')
432
+ })
433
+
434
+ test('list has default number of items', ({ assert }) => {
435
+ const result = catalog.versionInfos()
436
+ assert.lengthOf(result, 5)
437
+ })
438
+
439
+ test('returns requested number of items', ({ assert }) => {
440
+ const result = catalog.versionInfos(8)
441
+ assert.lengthOf(result, 8)
442
+ })
443
+
444
+ test('calls versionInfo()', ({ assert }) => {
445
+ const spy = sinon.spy(catalog, 'versionInfo')
446
+ catalog.versionInfos(6)
447
+ assert.equal(spy.callCount, 6)
448
+ })
449
+ })