@api-client/core 0.18.49 → 0.18.50

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 (47) hide show
  1. package/build/src/mocking/lib/DataCatalog.d.ts +4 -4
  2. package/build/src/mocking/lib/DataCatalog.d.ts.map +1 -1
  3. package/build/src/mocking/lib/DataCatalog.js +8 -8
  4. package/build/src/mocking/lib/DataCatalog.js.map +1 -1
  5. package/build/src/mocking/lib/File.d.ts +2 -2
  6. package/build/src/mocking/lib/File.d.ts.map +1 -1
  7. package/build/src/mocking/lib/File.js +5 -5
  8. package/build/src/mocking/lib/File.js.map +1 -1
  9. package/build/src/mocking/lib/Group.d.ts +1 -1
  10. package/build/src/mocking/lib/Group.d.ts.map +1 -1
  11. package/build/src/mocking/lib/Group.js +2 -2
  12. package/build/src/mocking/lib/Group.js.map +1 -1
  13. package/build/src/mocking/lib/Invitation.d.ts +1 -1
  14. package/build/src/mocking/lib/Invitation.d.ts.map +1 -1
  15. package/build/src/mocking/lib/Invitation.js +2 -2
  16. package/build/src/mocking/lib/Invitation.js.map +1 -1
  17. package/build/src/mocking/lib/Organization.d.ts +1 -1
  18. package/build/src/mocking/lib/Organization.d.ts.map +1 -1
  19. package/build/src/mocking/lib/Organization.js +2 -2
  20. package/build/src/mocking/lib/Organization.js.map +1 -1
  21. package/build/src/mocking/lib/Patch.d.ts +1 -1
  22. package/build/src/mocking/lib/Patch.d.ts.map +1 -1
  23. package/build/src/mocking/lib/Patch.js +2 -2
  24. package/build/src/mocking/lib/Patch.js.map +1 -1
  25. package/build/src/mocking/lib/Trash.d.ts +1 -1
  26. package/build/src/mocking/lib/Trash.d.ts.map +1 -1
  27. package/build/src/mocking/lib/Trash.js +2 -2
  28. package/build/src/mocking/lib/Trash.js.map +1 -1
  29. package/build/tsconfig.tsbuildinfo +1 -1
  30. package/data/models/example-generator-api.json +9 -9
  31. package/package.json +1 -1
  32. package/src/mocking/README.md +40 -0
  33. package/src/mocking/lib/DataCatalog.ts +8 -8
  34. package/src/mocking/lib/File.ts +5 -5
  35. package/src/mocking/lib/Group.ts +2 -2
  36. package/src/mocking/lib/Invitation.ts +2 -2
  37. package/src/mocking/lib/Organization.ts +2 -2
  38. package/src/mocking/lib/Patch.ts +2 -2
  39. package/src/mocking/lib/Trash.ts +2 -2
  40. package/src/models/README.md +5 -4
  41. package/tests/unit/mocking/current/DataCatalog.spec.ts +28 -0
  42. package/tests/unit/mocking/current/File.spec.ts +79 -0
  43. package/tests/unit/mocking/current/Group.spec.ts +49 -0
  44. package/tests/unit/mocking/current/Invitation.spec.ts +49 -0
  45. package/tests/unit/mocking/current/Organization.spec.ts +50 -0
  46. package/tests/unit/mocking/current/Patch.spec.ts +47 -0
  47. package/tests/unit/mocking/current/Trash.spec.ts +49 -0
@@ -42813,13 +42813,13 @@
42813
42813
  "@id": "#210"
42814
42814
  },
42815
42815
  {
42816
- "@id": "#213"
42816
+ "@id": "#219"
42817
42817
  },
42818
42818
  {
42819
- "@id": "#216"
42819
+ "@id": "#213"
42820
42820
  },
42821
42821
  {
42822
- "@id": "#219"
42822
+ "@id": "#216"
42823
42823
  }
42824
42824
  ],
42825
42825
  "doc:root": false,
@@ -44253,7 +44253,7 @@
44253
44253
  "doc:ExternalDomainElement",
44254
44254
  "doc:DomainElement"
44255
44255
  ],
44256
- "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
44256
+ "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
44257
44257
  "core:mediaType": "application/yaml",
44258
44258
  "sourcemaps:sources": [
44259
44259
  {
@@ -44274,7 +44274,7 @@
44274
44274
  "doc:ExternalDomainElement",
44275
44275
  "doc:DomainElement"
44276
44276
  ],
44277
- "doc:raw": "-\n type: 'GENERAL'\n value: 'info@company.be'\n-\n type: 'IT_DEPT'\n value: 'it-service@company.be'\n",
44277
+ "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
44278
44278
  "core:mediaType": "application/yaml",
44279
44279
  "sourcemaps:sources": [
44280
44280
  {
@@ -44295,7 +44295,7 @@
44295
44295
  "doc:ExternalDomainElement",
44296
44296
  "doc:DomainElement"
44297
44297
  ],
44298
- "doc:raw": "type: \"GENERAL\"\nvalue: \"www.company.be\"\n",
44298
+ "doc:raw": "type: 'GENERAL'\ncountryDialCode : '+32'\nareaCode : '21'\nsubscriberNumber: '12.87.00'\nformatted: '+32-(0)21 302099'\n",
44299
44299
  "core:mediaType": "application/yaml",
44300
44300
  "sourcemaps:sources": [
44301
44301
  {
@@ -45121,17 +45121,17 @@
45121
45121
  {
45122
45122
  "@id": "#215/source-map/lexical/element_0",
45123
45123
  "sourcemaps:element": "amf://id#215",
45124
- "sourcemaps:value": "[(1,0)-(6,0)]"
45124
+ "sourcemaps:value": "[(1,0)-(7,0)]"
45125
45125
  },
45126
45126
  {
45127
45127
  "@id": "#218/source-map/lexical/element_0",
45128
45128
  "sourcemaps:element": "amf://id#218",
45129
- "sourcemaps:value": "[(1,0)-(7,0)]"
45129
+ "sourcemaps:value": "[(1,0)-(3,0)]"
45130
45130
  },
45131
45131
  {
45132
45132
  "@id": "#221/source-map/lexical/element_0",
45133
45133
  "sourcemaps:element": "amf://id#221",
45134
- "sourcemaps:value": "[(1,0)-(3,0)]"
45134
+ "sourcemaps:value": "[(1,0)-(6,0)]"
45135
45135
  },
45136
45136
  {
45137
45137
  "@id": "#338/source-map/synthesized-field/element_1",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@api-client/core",
3
3
  "description": "The API Client's core client library. Works in NodeJS and in a ES enabled browser.",
4
- "version": "0.18.49",
4
+ "version": "0.18.50",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  "./browser.js": {
@@ -0,0 +1,40 @@
1
+ # Mocking Library (`src/mocking`)
2
+
3
+ This directory contains the mocking infrastructure for the API Cloud Core. It provides realistic data generation for testing and demo purposes without requiring a real backend.
4
+
5
+ ## Key Components
6
+
7
+ ### `ProjectMock`
8
+ The main entry point for mocking a project environment. It aggregates various sub-mocks to simulate a complete project context.
9
+
10
+ **Usage:**
11
+ ```typescript
12
+ import { ProjectMock } from './ProjectMock';
13
+
14
+ const mock = new ProjectMock();
15
+ // Access sub-mocks
16
+ console.log(mock.user);
17
+ console.log(mock.projectRequest);
18
+ ```
19
+
20
+ ### `ModelingMock` & `LegacyMock`
21
+ Specialized mocks for specific domains:
22
+ - `ModelingMock`: Logic for API domain modeling.
23
+ - `LegacyMock`: Support for older systems or deprecated interfaces.
24
+
25
+ ## Directory Structure
26
+
27
+ - **`lib/`**: Contains the individual mock implementations.
28
+ - `DataCatalog.ts`: Generates `DataCatalogSchema` objects using `faker`.
29
+ - `File.ts`, `User.ts`, `Request.ts`: Other domain-specific entities.
30
+ - **Pattern**: Classes in `lib/` usually provide methods like `entityName(init)` and `entityNames(size, init)` to generate single or multiple mock objects.
31
+ - **`legacy/`**: Old mock implementations kept for backward compatibility. Use with caution.
32
+
33
+ ## Developing Mocks
34
+
35
+ When adding a new mock:
36
+ 1. Create a class in `lib/` (e.g., `NewEntity.ts`).
37
+ 2. Use `@faker-js/faker` for realistic random data.
38
+ 3. Allow overrides via a partial `init` parameter.
39
+ 4. Export single and list generation methods.
40
+ 5. Register it in `ProjectMock.ts` if it belongs to the global project context.
@@ -53,10 +53,10 @@ export class DataCatalog {
53
53
  * @param size Number of data catalogs to generate. Default is 25.
54
54
  * @returns List of random data catalogs
55
55
  */
56
- dataCatalogs(size = 25): DataCatalogSchema[] {
56
+ dataCatalogs(size = 25, init?: Partial<DataCatalogSchema>): DataCatalogSchema[] {
57
57
  const result = []
58
58
  for (let i = 0; i < size; i++) {
59
- result.push(this.dataCatalog())
59
+ result.push(this.dataCatalog(init))
60
60
  }
61
61
  return result
62
62
  }
@@ -97,10 +97,10 @@ export class DataCatalog {
97
97
  * @param size Number of data catalog versions to generate. Default is 25.
98
98
  * @returns List of random data catalog versions.
99
99
  */
100
- dataCatalogVersions(size = 25): DataCatalogVersionSchema[] {
100
+ dataCatalogVersions(size = 25, init?: Partial<DataCatalogVersionSchema>): DataCatalogVersionSchema[] {
101
101
  const result = []
102
102
  for (let i = 0; i < size; i++) {
103
- result.push(this.dataCatalogVersion())
103
+ result.push(this.dataCatalogVersion(init))
104
104
  }
105
105
  return result
106
106
  }
@@ -129,10 +129,10 @@ export class DataCatalog {
129
129
  * @param size Number of data catalogs to generate. Default is 3.
130
130
  * @returns List of random data catalogs with versions.
131
131
  */
132
- dataCatalogsWithVersion(size = 3): DataCatalogSchemaWithVersion[] {
132
+ dataCatalogsWithVersion(size = 3, init?: Partial<DataCatalogSchemaWithVersion>): DataCatalogSchemaWithVersion[] {
133
133
  const result = []
134
134
  for (let i = 0; i < size; i++) {
135
- result.push(this.dataCatalogWithVersion())
135
+ result.push(this.dataCatalogWithVersion(init))
136
136
  }
137
137
  return result
138
138
  }
@@ -156,10 +156,10 @@ export class DataCatalog {
156
156
  * @param size Number of data catalog version info objects to generate. Default is 5.
157
157
  * @returns List of random data catalog version info objects.
158
158
  */
159
- versionInfos(size = 5): DataCatalogVersionInfo[] {
159
+ versionInfos(size = 5, init?: Partial<DataCatalogVersionInfo>): DataCatalogVersionInfo[] {
160
160
  const result = []
161
161
  for (let i = 0; i < size; i++) {
162
- result.push(this.versionInfo())
162
+ result.push(this.versionInfo(init))
163
163
  }
164
164
  return result
165
165
  }
@@ -15,7 +15,7 @@ export class File {
15
15
  kind = faker.helpers.arrayElement([ProjectKind, DomainFileKind, CertificateFileKind, ApiFileKind] as const),
16
16
  info = { name: faker.system.fileName() },
17
17
  } = init
18
- return CoreFile.createSchema({ kind, info })
18
+ return CoreFile.createSchema({ ...init, kind, info })
19
19
  }
20
20
 
21
21
  /**
@@ -23,10 +23,10 @@ export class File {
23
23
  * @param size Number of files to generate. Default is 25.
24
24
  * @returns List of random files
25
25
  */
26
- files(size = 25): IFile[] {
26
+ files(size = 25, init?: Partial<IFile>): IFile[] {
27
27
  const result = []
28
28
  for (let i = 0; i < size; i++) {
29
- result.push(this.file())
29
+ result.push(this.file(init))
30
30
  }
31
31
  return result
32
32
  }
@@ -45,10 +45,10 @@ export class File {
45
45
  * @param size Number of folders to generate. Default is 25.
46
46
  * @returns List of random folders
47
47
  */
48
- folders(size = 25): IFile[] {
48
+ folders(size = 25, init?: Partial<IFile>): IFile[] {
49
49
  const result = []
50
50
  for (let i = 0; i < size; i++) {
51
- result.push(this.folder())
51
+ result.push(this.folder(init))
52
52
  }
53
53
  return result
54
54
  }
@@ -42,10 +42,10 @@ export class Group {
42
42
  * @param size Number of organizations to generate. Default is 25.
43
43
  * @returns List of random organizations
44
44
  */
45
- groups(size = 25): GroupSchema[] {
45
+ groups(size = 25, init?: Partial<GroupSchema>): GroupSchema[] {
46
46
  const result = []
47
47
  for (let i = 0; i < size; i++) {
48
- result.push(this.group())
48
+ result.push(this.group(init))
49
49
  }
50
50
  return result
51
51
  }
@@ -48,10 +48,10 @@ export class Invitation {
48
48
  * @param size Number of invitations to generate. Default is 25.
49
49
  * @returns List of random invitations
50
50
  */
51
- invitations(size = 25): InvitationSchema[] {
51
+ invitations(size = 25, init?: Partial<InvitationSchema>): InvitationSchema[] {
52
52
  const result = []
53
53
  for (let i = 0; i < size; i++) {
54
- result.push(this.invitation())
54
+ result.push(this.invitation(init))
55
55
  }
56
56
  return result
57
57
  }
@@ -32,10 +32,10 @@ export class Organization {
32
32
  * @param size Number of organizations to generate. Default is 25.
33
33
  * @returns List of random organizations
34
34
  */
35
- organizations(size = 25): IOrganization[] {
35
+ organizations(size = 25, init?: Partial<IOrganization>): IOrganization[] {
36
36
  const result = []
37
37
  for (let i = 0; i < size; i++) {
38
- result.push(this.organization())
38
+ result.push(this.organization(init))
39
39
  }
40
40
  return result
41
41
  }
@@ -41,10 +41,10 @@ export class Patch {
41
41
  * @param size Number of invitations to generate. Default is 25.
42
42
  * @returns List of random invitations
43
43
  */
44
- mediaPatchRevisions(size = 25): MediaPatchRevision[] {
44
+ mediaPatchRevisions(size = 25, init?: Partial<MediaPatchRevision>): MediaPatchRevision[] {
45
45
  const result = []
46
46
  for (let i = 0; i < size; i++) {
47
- result.push(this.mediaPatchRevision())
47
+ result.push(this.mediaPatchRevision(init))
48
48
  }
49
49
  return result
50
50
  }
@@ -37,10 +37,10 @@ export class Trash {
37
37
  * @param size Number of invitations to generate. Default is 25.
38
38
  * @returns List of random invitations
39
39
  */
40
- trashEntries(size = 25): CoreTrashEntry[] {
40
+ trashEntries(size = 25, init?: Partial<CoreTrashEntry>): CoreTrashEntry[] {
41
41
  const result = []
42
42
  for (let i = 0; i < size; i++) {
43
- result.push(this.trashEntry())
43
+ result.push(this.trashEntry(init))
44
44
  }
45
45
  return result
46
46
  }
@@ -7,14 +7,15 @@
7
7
  Data models should only contain the data related to the functionality, and not view.
8
8
  Each application should keep separate metadata related to the view configuration.
9
9
 
10
- ### Translatable from a YAML format
11
-
12
- We aim to be interoperable with AMF so when designing a data model first design a YAML example with the data and then create a type definition. Additionally, you need to design an AML dialect for the data.
13
-
14
10
  ### The "kind" as the object type identifier
15
11
 
16
12
  Each data object that can exist by itself or in multiple contexts' should contain the `kind` property that uniquely identifies the type. For example, the `HttpProject` class has the `Core#HttpProject`. These kinds are used by other libraries to identify which data types they are given as the input.
13
+ Kinds are defined in the `src/models/kinds.ts` file.
17
14
 
18
15
  ### Validation
19
16
 
20
17
  THe data models should contain validators that produce the validation report. This ensures the support libraries can perform a validation of the data model they are receiving as an input to keep integrity of the data.
18
+
19
+ ## The "store" models
20
+
21
+ All models under the `src/models/store` directory are considered "API" related models. For example, the `File` model is used to describe the file object in the API, but it is not used as any application's core data model.
@@ -138,6 +138,13 @@ test.group('dataCatalogs()', (group) => {
138
138
  catalog.dataCatalogs(5)
139
139
  assert.equal(spy.callCount, 5)
140
140
  })
141
+
142
+ test('uses passed initialization values', ({ assert }) => {
143
+ const result = catalog.dataCatalogs(3, { name: 'Batch Catalog' })
144
+ result.forEach((item) => {
145
+ assert.equal(item.name, 'Batch Catalog')
146
+ })
147
+ })
141
148
  })
142
149
 
143
150
  test.group('dataCatalogVersion()', (group) => {
@@ -265,6 +272,13 @@ test.group('dataCatalogVersions()', (group) => {
265
272
  catalog.dataCatalogVersions(3)
266
273
  assert.equal(spy.callCount, 3)
267
274
  })
275
+
276
+ test('uses passed initialization values', ({ assert }) => {
277
+ const result = catalog.dataCatalogVersions(3, { version: 'v1.2.3' })
278
+ result.forEach((item) => {
279
+ assert.equal(item.version, 'v1.2.3')
280
+ })
281
+ })
268
282
  })
269
283
 
270
284
  test.group('dataCatalogWithVersion()', (group) => {
@@ -372,6 +386,13 @@ test.group('dataCatalogsWithVersion()', (group) => {
372
386
  assert.isAtLeast(item.versions.length, 1)
373
387
  })
374
388
  })
389
+
390
+ test('uses passed initialization values', ({ assert }) => {
391
+ const result = catalog.dataCatalogsWithVersion(3, { name: 'Versioned Batch' })
392
+ result.forEach((item) => {
393
+ assert.equal(item.name, 'Versioned Batch')
394
+ })
395
+ })
375
396
  })
376
397
 
377
398
  test.group('versionInfo()', (group) => {
@@ -446,4 +467,11 @@ test.group('versionInfos()', (group) => {
446
467
  catalog.versionInfos(6)
447
468
  assert.equal(spy.callCount, 6)
448
469
  })
470
+
471
+ test('uses passed initialization values', ({ assert }) => {
472
+ const result = catalog.versionInfos(3, { version: 'v9.9.9' })
473
+ result.forEach((item) => {
474
+ assert.equal(item.version, 'v9.9.9')
475
+ })
476
+ })
449
477
  })
@@ -0,0 +1,79 @@
1
+ import { test } from '@japa/runner'
2
+ import { File } from '../../../../src/mocking/lib/File.js'
3
+ import { FolderKind, ProjectKind } from '../../../../src/models/kinds.js'
4
+ import type { IFile } from '../../../../src/models/store/File.js'
5
+
6
+ test.group('File', (group) => {
7
+ let fileMock: File
8
+
9
+ group.each.setup(() => {
10
+ fileMock = new File()
11
+ })
12
+
13
+ test('file() returns a valid object', ({ assert }) => {
14
+ const result = fileMock.file()
15
+ assert.typeOf(result, 'object')
16
+ assert.property(result, 'kind')
17
+ assert.property(result, 'info')
18
+ })
19
+
20
+ test('file(init) allows overriding properties', ({ assert }) => {
21
+ const init: Partial<IFile> = {
22
+ kind: ProjectKind,
23
+ info: { name: 'My Project' },
24
+ }
25
+ const result = fileMock.file(init)
26
+ assert.equal(result.kind, ProjectKind)
27
+ assert.equal(result.info.name, 'My Project')
28
+ })
29
+
30
+ test('files() returns a list', ({ assert }) => {
31
+ const result = fileMock.files(5)
32
+ assert.isArray(result)
33
+ assert.lengthOf(result, 5)
34
+ })
35
+
36
+ test('files(size, init) allows overriding properties', ({ assert }) => {
37
+ const init: Partial<IFile> = {
38
+ kind: ProjectKind,
39
+ }
40
+ const result = fileMock.files(3, init)
41
+ assert.lengthOf(result, 3)
42
+ result.forEach((item) => {
43
+ assert.equal(item.kind, ProjectKind)
44
+ })
45
+ })
46
+
47
+ test('folder() returns a valid object', ({ assert }) => {
48
+ const result = fileMock.folder()
49
+ assert.typeOf(result, 'object')
50
+ assert.equal(result.kind, FolderKind)
51
+ })
52
+
53
+ test('folder(init) allows overriding properties', ({ assert }) => {
54
+ const init: Partial<IFile> = {
55
+ key: 'custom-folder-key',
56
+ }
57
+ const result = fileMock.folder(init)
58
+ assert.equal(result.kind, FolderKind)
59
+ assert.equal(result.key, 'custom-folder-key')
60
+ })
61
+
62
+ test('folders() returns a list', ({ assert }) => {
63
+ const result = fileMock.folders(5)
64
+ assert.isArray(result)
65
+ assert.lengthOf(result, 5)
66
+ })
67
+
68
+ test('folders(size, init) allows overriding properties', ({ assert }) => {
69
+ const init: Partial<IFile> = {
70
+ key: 'batch-key',
71
+ }
72
+ const result = fileMock.folders(3, init)
73
+ assert.lengthOf(result, 3)
74
+ result.forEach((item) => {
75
+ assert.equal(item.kind, FolderKind)
76
+ assert.equal(item.key, 'batch-key')
77
+ })
78
+ })
79
+ })
@@ -0,0 +1,49 @@
1
+ import { test } from '@japa/runner'
2
+ import { Group } from '../../../../src/mocking/lib/Group.js'
3
+ import { GroupKind } from '../../../../src/models/kinds.js'
4
+ import type { GroupSchema } from '../../../../src/models/store/Group.js'
5
+
6
+ test.group('Group', (group) => {
7
+ let groupMock: Group
8
+
9
+ group.each.setup(() => {
10
+ groupMock = new Group()
11
+ })
12
+
13
+ test('group() returns a valid object', ({ assert }) => {
14
+ const result = groupMock.group()
15
+ assert.typeOf(result, 'object')
16
+ assert.equal(result.kind, GroupKind)
17
+ assert.property(result, 'key')
18
+ assert.property(result, 'name')
19
+ assert.property(result, 'color')
20
+ assert.property(result, 'users')
21
+ })
22
+
23
+ test('group(init) allows overriding properties', ({ assert }) => {
24
+ const init: Partial<GroupSchema> = {
25
+ name: 'Custom Group',
26
+ color: '#ff0000',
27
+ }
28
+ const result = groupMock.group(init)
29
+ assert.equal(result.name, 'Custom Group')
30
+ assert.equal(result.color, '#ff0000')
31
+ })
32
+
33
+ test('groups() returns a list', ({ assert }) => {
34
+ const result = groupMock.groups(5)
35
+ assert.isArray(result)
36
+ assert.lengthOf(result, 5)
37
+ })
38
+
39
+ test('groups(size, init) allows overriding properties', ({ assert }) => {
40
+ const init: Partial<GroupSchema> = {
41
+ description: 'Batch Description',
42
+ }
43
+ const result = groupMock.groups(3, init)
44
+ assert.lengthOf(result, 3)
45
+ result.forEach((item) => {
46
+ assert.equal(item.description, 'Batch Description')
47
+ })
48
+ })
49
+ })
@@ -0,0 +1,49 @@
1
+ import { test } from '@japa/runner'
2
+ import { Invitation } from '../../../../src/mocking/lib/Invitation.js'
3
+ import { InvitationKind } from '../../../../src/models/kinds.js'
4
+ import type { InvitationSchema } from '../../../../src/models/store/Invitation.js'
5
+
6
+ test.group('Invitation', (group) => {
7
+ let invitation: Invitation
8
+
9
+ group.each.setup(() => {
10
+ invitation = new Invitation()
11
+ })
12
+
13
+ test('invitation() returns a valid object', ({ assert }) => {
14
+ const result = invitation.invitation()
15
+ assert.typeOf(result, 'object')
16
+ assert.equal(result.kind, InvitationKind)
17
+ assert.property(result, 'key')
18
+ assert.property(result, 'email')
19
+ assert.property(result, 'token')
20
+ assert.property(result, 'status')
21
+ })
22
+
23
+ test('invitation(init) allows overriding properties', ({ assert }) => {
24
+ const init: Partial<InvitationSchema> = {
25
+ email: 'test@example.com',
26
+ status: 'accepted',
27
+ }
28
+ const result = invitation.invitation(init)
29
+ assert.equal(result.email, 'test@example.com')
30
+ assert.equal(result.status, 'accepted')
31
+ })
32
+
33
+ test('invitations() returns a list', ({ assert }) => {
34
+ const result = invitation.invitations(5)
35
+ assert.isArray(result)
36
+ assert.lengthOf(result, 5)
37
+ })
38
+
39
+ test('invitations(size, init) allows overriding properties', ({ assert }) => {
40
+ const init: Partial<InvitationSchema> = {
41
+ status: 'declined',
42
+ }
43
+ const result = invitation.invitations(3, init)
44
+ assert.lengthOf(result, 3)
45
+ result.forEach((item) => {
46
+ assert.equal(item.status, 'declined')
47
+ })
48
+ })
49
+ })
@@ -0,0 +1,50 @@
1
+ import { test } from '@japa/runner'
2
+ import { Organization } from '../../../../src/mocking/lib/Organization.js'
3
+ import { OrganizationKind } from '../../../../src/models/kinds.js'
4
+ import type { IOrganization } from '../../../../src/models/store/Organization.js'
5
+
6
+ test.group('Organization', (group) => {
7
+ let organization: Organization
8
+
9
+ group.each.setup(() => {
10
+ organization = new Organization()
11
+ })
12
+
13
+ test('organization() returns a valid object', ({ assert }) => {
14
+ const result = organization.organization()
15
+ assert.typeOf(result, 'object')
16
+ assert.equal(result.kind, OrganizationKind)
17
+ assert.property(result, 'key')
18
+ assert.property(result, 'name')
19
+ assert.property(result, 'createdBy')
20
+ assert.property(result, 'createdDate')
21
+ assert.property(result, 'grantType')
22
+ })
23
+
24
+ test('organization(init) allows overriding properties', ({ assert }) => {
25
+ const init: Partial<IOrganization> = {
26
+ key: 'custom-org-key',
27
+ name: 'Custom Org',
28
+ }
29
+ const result = organization.organization(init)
30
+ assert.equal(result.key, 'custom-org-key')
31
+ assert.equal(result.name, 'Custom Org')
32
+ })
33
+
34
+ test('organizations() returns a list', ({ assert }) => {
35
+ const result = organization.organizations(5)
36
+ assert.isArray(result)
37
+ assert.lengthOf(result, 5)
38
+ })
39
+
40
+ test('organizations(size, init) allows overriding properties', ({ assert }) => {
41
+ const init: Partial<IOrganization> = {
42
+ name: 'Batch Org',
43
+ }
44
+ const result = organization.organizations(3, init)
45
+ assert.lengthOf(result, 3)
46
+ result.forEach((item) => {
47
+ assert.equal(item.name, 'Batch Org')
48
+ })
49
+ })
50
+ })
@@ -0,0 +1,47 @@
1
+ import { test } from '@japa/runner'
2
+ import { Patch } from '../../../../src/mocking/lib/Patch.js'
3
+ import type { MediaPatchRevision } from '../../../../src/patch/types.js'
4
+
5
+ test.group('Patch', (group) => {
6
+ let patch: Patch
7
+
8
+ group.each.setup(() => {
9
+ patch = new Patch()
10
+ })
11
+
12
+ test('mediaPatchRevision() returns a valid object', ({ assert }) => {
13
+ const result = patch.mediaPatchRevision()
14
+ assert.typeOf(result, 'object')
15
+ assert.property(result, 'id')
16
+ assert.property(result, 'timestamp')
17
+ assert.property(result, 'patch')
18
+ assert.property(result, 'version')
19
+ })
20
+
21
+ test('mediaPatchRevision(init) allows overriding properties', ({ assert }) => {
22
+ const init: Partial<MediaPatchRevision> = {
23
+ id: 'custom-id',
24
+ version: 99,
25
+ }
26
+ const result = patch.mediaPatchRevision(init)
27
+ assert.equal(result.id, 'custom-id')
28
+ assert.equal(result.version, 99)
29
+ })
30
+
31
+ test('mediaPatchRevisions() returns a list', ({ assert }) => {
32
+ const result = patch.mediaPatchRevisions(5)
33
+ assert.isArray(result)
34
+ assert.lengthOf(result, 5)
35
+ })
36
+
37
+ test('mediaPatchRevisions(size, init) allows overriding properties', ({ assert }) => {
38
+ const init: Partial<MediaPatchRevision> = {
39
+ version: 123,
40
+ }
41
+ const result = patch.mediaPatchRevisions(3, init)
42
+ assert.lengthOf(result, 3)
43
+ result.forEach((item) => {
44
+ assert.equal(item.version, 123)
45
+ })
46
+ })
47
+ })
@@ -0,0 +1,49 @@
1
+ import { test } from '@japa/runner'
2
+ import { Trash } from '../../../../src/mocking/lib/Trash.js'
3
+ import { ProjectKind } from '../../../../src/models/kinds.js'
4
+ import type { TrashEntry } from '../../../../src/models/TrashEntry.js'
5
+
6
+ test.group('Trash', (group) => {
7
+ let trash: Trash
8
+
9
+ group.each.setup(() => {
10
+ trash = new Trash()
11
+ })
12
+
13
+ test('trashEntry() returns a valid object', ({ assert }) => {
14
+ const result = trash.trashEntry()
15
+ assert.typeOf(result, 'object')
16
+ assert.property(result, 'key')
17
+ assert.property(result, 'refKey')
18
+ assert.property(result, 'kind')
19
+ assert.property(result, 'info')
20
+ assert.property(result, 'capabilities')
21
+ })
22
+
23
+ test('trashEntry(init) allows overriding properties', ({ assert }) => {
24
+ const init: Partial<TrashEntry> = {
25
+ key: 'custom-key',
26
+ kind: ProjectKind,
27
+ }
28
+ const result = trash.trashEntry(init)
29
+ assert.equal(result.key, 'custom-key')
30
+ assert.equal(result.kind, ProjectKind)
31
+ })
32
+
33
+ test('trashEntries() returns a list', ({ assert }) => {
34
+ const result = trash.trashEntries(5)
35
+ assert.isArray(result)
36
+ assert.lengthOf(result, 5)
37
+ })
38
+
39
+ test('trashEntries(size, init) allows overriding properties', ({ assert }) => {
40
+ const init: Partial<TrashEntry> = {
41
+ kind: ProjectKind,
42
+ }
43
+ const result = trash.trashEntries(3, init)
44
+ assert.lengthOf(result, 3)
45
+ result.forEach((item) => {
46
+ assert.equal(item.kind, ProjectKind)
47
+ })
48
+ })
49
+ })