@toa.io/userland 1.0.0-alpha.7 → 1.0.0-alpha.9

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 (98) hide show
  1. package/package.json +9 -9
  2. package/readme.md +0 -2
  3. package/example/components/echo/samples/get.yaml +0 -12
  4. package/example/components/echo/samples/signal.yaml +0 -4
  5. package/example/components/math.calculations/samples/add.yaml +0 -10
  6. package/example/components/math.calculations/samples/assets/ab.yaml +0 -2
  7. package/example/components/math.calculations/samples/increment.yaml +0 -27
  8. package/example/components/math.proxy/samples/add.yaml +0 -11
  9. package/example/components/tea.pots/samples/same.yaml +0 -8
  10. package/example/components/tea.pots/samples/transit.yaml +0 -43
  11. package/example/components/web/samples/get.yaml +0 -8
  12. package/example/samples/math.proxy.add.yaml +0 -5
  13. package/example/samples/messages/store.orders.created.yaml +0 -8
  14. package/samples/docs/sampling-dark.jpg +0 -0
  15. package/samples/docs/sampling-light.jpg +0 -0
  16. package/samples/notes.md +0 -12
  17. package/samples/package.json +0 -5
  18. package/samples/readme.md +0 -131
  19. package/samples/src/.replay/.suite/component.js +0 -20
  20. package/samples/src/.replay/.suite/index.js +0 -7
  21. package/samples/src/.replay/.suite/messages.js +0 -39
  22. package/samples/src/.replay/.suite/operation.js +0 -28
  23. package/samples/src/.replay/.suite/operations.js +0 -20
  24. package/samples/src/.replay/.suite/translate/.message/index.js +0 -5
  25. package/samples/src/.replay/.suite/translate/.message/request.js +0 -31
  26. package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.js +0 -20
  27. package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.test.js +0 -94
  28. package/samples/src/.replay/.suite/translate/.operation/.prepare/expand.js +0 -14
  29. package/samples/src/.replay/.suite/translate/.operation/.prepare/index.js +0 -7
  30. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/.aspect.js +0 -26
  31. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/configuration.js +0 -5
  32. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/http.js +0 -5
  33. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/index.js +0 -9
  34. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/state.js +0 -5
  35. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/async.js +0 -3
  36. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/cast.js +0 -26
  37. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/index.js +0 -5
  38. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/map.js +0 -3
  39. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/set.js +0 -3
  40. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/sync.js +0 -3
  41. package/samples/src/.replay/.suite/translate/.operation/calls.js +0 -49
  42. package/samples/src/.replay/.suite/translate/.operation/cleanup.js +0 -16
  43. package/samples/src/.replay/.suite/translate/.operation/events.js +0 -16
  44. package/samples/src/.replay/.suite/translate/.operation/index.js +0 -11
  45. package/samples/src/.replay/.suite/translate/.operation/prepare.js +0 -14
  46. package/samples/src/.replay/.suite/translate/index.js +0 -7
  47. package/samples/src/.replay/.suite/translate/message.js +0 -26
  48. package/samples/src/.replay/.suite/translate/operation.js +0 -47
  49. package/samples/src/.replay/.suite/translate/schemas/index.js +0 -7
  50. package/samples/src/.replay/.suite/translate/schemas/message.cos.yaml +0 -10
  51. package/samples/src/.replay/.suite/translate/schemas/operation.cos.yaml +0 -23
  52. package/samples/src/.replay/index.js +0 -7
  53. package/samples/src/.replay/stage.js +0 -60
  54. package/samples/src/.replay/suite.js +0 -23
  55. package/samples/src/.replay/test.js +0 -19
  56. package/samples/src/components.js +0 -13
  57. package/samples/src/context.js +0 -23
  58. package/samples/src/index.js +0 -9
  59. package/samples/src/replay.js +0 -16
  60. package/samples/src/suite/.read/filter.js +0 -15
  61. package/samples/src/suite/.read/index.js +0 -7
  62. package/samples/src/suite/.read/messages.js +0 -40
  63. package/samples/src/suite/.read/operations.js +0 -51
  64. package/samples/src/suite/.read/parse.js +0 -20
  65. package/samples/src/suite/components.js +0 -31
  66. package/samples/src/suite/context.js +0 -20
  67. package/samples/src/suite/index.js +0 -7
  68. package/samples/test/components.test.js +0 -42
  69. package/samples/test/context/components/dummy/manifest.toa.yaml +0 -2
  70. package/samples/test/context/components/dummy/samples/do.yaml +0 -11
  71. package/samples/test/context/components/dummy/samples/dummies.dummy.do.yaml +0 -11
  72. package/samples/test/context/components/dummy/samples/dummies.dummy.undo.yaml +0 -7
  73. package/samples/test/context/components/dummy/samples/messages/somewhere.something.happened.yaml +0 -6
  74. package/samples/test/context/components/pot/manifest.toa.yaml +0 -2
  75. package/samples/test/context/components/pot/samples/do.yaml +0 -11
  76. package/samples/test/context/components/pot/samples/messages/somewhere.something.happened.yaml +0 -6
  77. package/samples/test/context/context.toa.yaml +0 -3
  78. package/samples/test/context/samples/dummies.dummy.observe.yaml +0 -6
  79. package/samples/test/context/samples/dummies.dummy.transit.yaml +0 -10
  80. package/samples/test/context/samples/messages/somewhere.something.happened.yaml +0 -6
  81. package/samples/test/context.fixtures.js +0 -8
  82. package/samples/test/context.test.js +0 -82
  83. package/samples/test/replay.mock.js +0 -7
  84. package/samples/test/replay.test.js +0 -152
  85. package/samples/test/replay.translate.message.fixtures.js +0 -24
  86. package/samples/test/replay.translate.message.test.js +0 -119
  87. package/samples/test/replay.translate.mock.js +0 -17
  88. package/samples/test/replay.translate.operation.fixtures.js +0 -107
  89. package/samples/test/replay.translate.operation.test.js +0 -68
  90. package/samples/test/stage.mock.js +0 -30
  91. package/samples/test/suite.components.test.js +0 -122
  92. package/samples/test/suite.context.test.js +0 -79
  93. package/samples/test/suite.mock.js +0 -10
  94. package/samples/types/index.d.ts +0 -8
  95. package/samples/types/message.d.ts +0 -24
  96. package/samples/types/operation.d.ts +0 -36
  97. package/samples/types/replay.d.ts +0 -13
  98. package/samples/types/suite.d.ts +0 -31
@@ -1,31 +0,0 @@
1
- 'use strict'
2
-
3
- const norm = require('@toa.io/norm')
4
- const { merge } = require('@toa.io/generic')
5
-
6
- const read = require('./.read')
7
-
8
- /**
9
- * @param {string[]} paths
10
- * @param {toa.samples.suite.Options} [options]
11
- * @returns {Promise<toa.samples.Suite>}
12
- */
13
- const components = async (paths, options = {}) => {
14
- /** @type {toa.samples.Suite} */
15
- const suite = { title: 'Component samples', autonomous: true, operations: {} }
16
-
17
- for (const path of paths) {
18
- const manifest = await norm.component(path)
19
-
20
- options.id = manifest.locator.id
21
-
22
- const operations = await read.operations(path, options)
23
- // const messages = await read.messages(path, options)
24
-
25
- merge(suite, { operations })
26
- }
27
-
28
- return suite
29
- }
30
-
31
- exports.components = components
@@ -1,20 +0,0 @@
1
- 'use strict'
2
-
3
- const read = require('./.read')
4
-
5
- /**
6
- * @param {string} path
7
- * @param {toa.samples.suite.Options} [options]
8
- * @returns {Promise<toa.samples.Suite>}
9
- */
10
- const context = async (path, options = {}) => {
11
- /** @type {toa.samples.Suite} */
12
- const suite = { title: 'Integration samples', autonomous: false }
13
-
14
- suite.operations = await read.operations(path, options)
15
- suite.messages = await read.messages(path, options)
16
-
17
- return suite
18
- }
19
-
20
- exports.context = context
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { components } = require('./components')
4
- const { context } = require('./context')
5
-
6
- exports.components = components
7
- exports.context = context
@@ -1,42 +0,0 @@
1
- 'use strict'
2
-
3
- const { generate } = require('randomstring')
4
-
5
- const { suite } = require('./suite.mock')
6
- const { replay } = require('./replay.mock')
7
- const mock = { suite, replay }
8
-
9
- jest.mock('../src/suite', () => mock.suite)
10
- jest.mock('../src/replay', () => mock.replay)
11
-
12
- const { components } = require('../')
13
-
14
- it('should be', () => {
15
- expect(components).toBeDefined()
16
- })
17
-
18
- const paths = [generate()]
19
-
20
- /** @type {toa.samples.suite.Options} */
21
- const options = { component: generate(), runner: { [generate()]: generate() } }
22
-
23
- /** @type {boolean} */
24
- let result
25
-
26
- beforeAll(async () => {
27
- result = await components(paths, options)
28
- })
29
-
30
- it('should load suite', async () => {
31
- expect(mock.suite.components).toHaveBeenCalledWith(paths, options)
32
- })
33
-
34
- it('should replay suite', async () => {
35
- const suite = await mock.suite.components.mock.results[0].value
36
-
37
- expect(mock.replay.replay).toHaveBeenCalledWith(suite, paths, options.runner)
38
- })
39
-
40
- it('should return result', async () => {
41
- expect(result).toStrictEqual(await mock.replay.replay.mock.results[0].value)
42
- })
@@ -1,2 +0,0 @@
1
- namespace: dummies
2
- name: dummy
@@ -1,11 +0,0 @@
1
- title: First case
2
- input:
3
- foo: bar
4
- output:
5
- baz: true
6
- ---
7
- title: Second case
8
- input:
9
- foo: qux
10
- output:
11
- baz: false
@@ -1,11 +0,0 @@
1
- title: Third case
2
- input:
3
- foo: bar
4
- output:
5
- baz: true
6
- ---
7
- title: Fourth case
8
- input:
9
- foo: qux
10
- output:
11
- baz: false
@@ -1,7 +0,0 @@
1
- title: Should undo
2
- input: 1
3
- output: true
4
- ---
5
- title: Should not undo
6
- input: 0
7
- output: false
@@ -1,6 +0,0 @@
1
- title: Something happened with a dummy
2
- payload:
3
- foo: bar
4
- input: foo
5
- query:
6
- id: bar
@@ -1,2 +0,0 @@
1
- namespace: dummies
2
- name: pot
@@ -1,11 +0,0 @@
1
- title: First case
2
- input:
3
- foo: bar
4
- output:
5
- baz: true
6
- ---
7
- title: Second case
8
- input:
9
- foo: qux
10
- output:
11
- baz: false
@@ -1,6 +0,0 @@
1
- title: Something happened with a pot
2
- payload:
3
- foo: bar
4
- input: foo
5
- query:
6
- id: bar
@@ -1,3 +0,0 @@
1
- name: test
2
- packages: components/*
3
- registry: whatever.none
@@ -1,6 +0,0 @@
1
- title: Should observe
2
- query:
3
- id: 57022f11306149d8b246c9ea4a164079
4
- output:
5
- id: 57022f11306149d8b246c9ea4a164079
6
- bar: 2
@@ -1,10 +0,0 @@
1
- title: First sample
2
- input:
3
- foo: 1
4
- output:
5
- bar: 2
6
- ---
7
- input:
8
- foo: 2
9
- output:
10
- bar: 3
@@ -1,6 +0,0 @@
1
- title: First sample
2
- component: dummies.dummy
3
- payload:
4
- foo: 1
5
- input:
6
- bar: 2
@@ -1,8 +0,0 @@
1
- 'use strict'
2
-
3
- const { flip } = require('@toa.io/generic')
4
-
5
- const components = jest.fn(async () => flip())
6
- const mock = { components: { components } }
7
-
8
- exports.mock = mock
@@ -1,82 +0,0 @@
1
- 'use strict'
2
-
3
- const { resolve } = require('node:path')
4
- const { directory: { glob } } = require('@toa.io/filesystem')
5
-
6
- const fixtures = require('./context.fixtures')
7
- const { suite } = require('./suite.mock')
8
- const { replay } = require('./replay.mock')
9
-
10
- const mock = { suite, replay, ...fixtures.mock }
11
-
12
- jest.mock('../src/suite', () => mock.suite)
13
- jest.mock('../src/replay', () => mock.replay)
14
- jest.mock('../src/components', () => mock.components)
15
-
16
- const { context } = require('../src/context')
17
- const { generate } = require('randomstring')
18
-
19
- it('should be', async () => {
20
- expect(context).toBeDefined()
21
- })
22
-
23
- const CONTEXT = resolve(__dirname, './context')
24
- const COMPONENTS = resolve(CONTEXT, 'components/*')
25
-
26
- /** @type {string[]} */
27
- let paths
28
-
29
- /** @type {toa.samples.suite.Options} */
30
- const options = { component: generate(), runner: { [generate()]: generate() } }
31
-
32
- /** @type {boolean} */
33
- let ok
34
-
35
- beforeAll(async () => {
36
- paths = await glob(COMPONENTS)
37
- })
38
-
39
- beforeEach(async () => {
40
- jest.clearAllMocks()
41
-
42
- mock.components.components.mockImplementation(async () => true)
43
-
44
- ok = await context(CONTEXT, options)
45
- })
46
-
47
- it('should replay context components sample sets', async () => {
48
- expect(mock.components.components).toHaveBeenCalledWith(paths, options)
49
- })
50
-
51
- it('should load integration suite', async () => {
52
- expect(mock.suite.context).toHaveBeenCalledWith(CONTEXT, options)
53
- })
54
-
55
- it('should replay integration suite', async () => {
56
- const suite = await mock.suite.context.mock.results[0].value
57
-
58
- expect(replay.replay).toHaveBeenCalledWith(suite, paths, options.runner)
59
- })
60
-
61
- it('should return false if components replay failed', async () => {
62
- jest.clearAllMocks()
63
-
64
- mock.components.components.mockImplementation(async () => false)
65
-
66
- ok = await context(CONTEXT)
67
-
68
- expect(ok).toStrictEqual(false)
69
- expect(replay.replay).not.toHaveBeenCalled()
70
- })
71
-
72
- it('should return replay result if components replay ok', async () => {
73
- jest.clearAllMocks()
74
-
75
- mock.components.components.mockImplementation(async () => true)
76
-
77
- ok = await context(CONTEXT)
78
-
79
- const mocked = await mock.replay.replay.mock.results[0].value
80
-
81
- expect(ok).toStrictEqual(mocked)
82
- })
@@ -1,7 +0,0 @@
1
- 'use strict'
2
-
3
- const { generate } = require('randomstring')
4
-
5
- const replay = jest.fn(async () => generate())
6
-
7
- exports.replay = { replay }
@@ -1,152 +0,0 @@
1
- 'use strict'
2
-
3
- const { resolve } = require('node:path')
4
- const { directory } = require('@toa.io/filesystem')
5
-
6
- const { stage } = require('./stage.mock')
7
- const { translate } = require('./replay.translate.mock')
8
- const mock = { stage, translate }
9
-
10
- jest.mock('@toa.io/userland/stage', () => mock.stage)
11
- jest.mock('../src/.replay/.suite/translate', () => mock.translate)
12
-
13
- const load = require('../src/suite')
14
-
15
- const { replay } = require('../src')
16
-
17
- it('should be', () => {
18
- expect(replay).toBeDefined()
19
- })
20
-
21
- let ok
22
-
23
- /** @type {toa.samples.Suite} */
24
- let suite
25
-
26
- beforeEach(() => {
27
- jest.clearAllMocks()
28
- })
29
-
30
- describe('autonomous', () => {
31
- let paths
32
-
33
- beforeEach(async () => {
34
- const path = resolve(__dirname, '../../example/components/tea.pots')
35
-
36
- paths = [path]
37
- suite = await load.components(paths)
38
- ok = await replay(suite, paths)
39
- })
40
-
41
- it('should not boot composition for autonomous suite', async () => {
42
- expect(stage.composition).not.toHaveBeenCalled()
43
- })
44
-
45
- it('should invoke operations with translated samples', async () => {
46
- const component = await stage.component.mock.results[0].value
47
-
48
- for (const set of Object.values(suite.operations)) {
49
- for (const [endpoint, samples] of Object.entries(set)) {
50
- for (const sample of samples) {
51
- const request = translation(sample)
52
-
53
- expect(component.invoke).toHaveBeenCalledWith(endpoint, request)
54
- }
55
- }
56
- }
57
- })
58
- })
59
-
60
- describe('integration', () => {
61
- let paths
62
-
63
- beforeEach(async () => {
64
- const path = resolve(__dirname, '../../example')
65
-
66
- paths = await directory.directories(resolve(path, 'components'))
67
- suite = await load.context(path)
68
- ok = await replay(suite, paths)
69
- })
70
-
71
- it('should boot composition', () => {
72
- expect(stage.composition).toHaveBeenCalled()
73
- expect(stage.composition).toHaveBeenCalledWith(paths)
74
- })
75
-
76
- it('should invoke operations with translated samples', async () => {
77
- /**
78
- * @param {string} component
79
- * @return {jest.MockedObject<toa.core.Component>}
80
- */
81
- const getRemote = (component) => {
82
- for (let n = 0; n < stage.remote.mock.calls.length; n++) {
83
- const call = stage.remote.mock.calls[n]
84
-
85
- if (call[0] === component) return stage.remote.mock.results[n].value
86
- }
87
-
88
- throw new Error(`Remote ${component} hasn't been connected`)
89
- }
90
-
91
- for (const [id, set] of Object.entries(suite.operations)) {
92
- const remote = await getRemote(id)
93
-
94
- for (const [endpoint, samples] of Object.entries(set)) {
95
- for (const sample of samples) {
96
- const request = translation(sample)
97
-
98
- expect(remote.invoke).toHaveBeenCalledWith(endpoint, request)
99
- }
100
- }
101
- }
102
- })
103
-
104
- it('should emit translated messages', async () => {
105
- /**
106
- * @param {toa.samples.Message} declaration
107
- * @returns {{index: number, message: toa.sampling.Message}}
108
- */
109
- const translation = (declaration) => {
110
- const find = (call) => call[0].payload === declaration.payload
111
- const index = mock.translate.message.mock.calls.findIndex(find)
112
- const message = mock.translate.message.mock.results[index].value
113
- const call = mock.translate.message.mock.calls[index]
114
-
115
- expect(call[1]).toStrictEqual(suite.autonomous)
116
-
117
- return { index, message }
118
- }
119
-
120
- for (const [label, samples] of Object.entries(suite.messages)) {
121
- for (const sample of samples) {
122
- const { index, message } = translation(sample)
123
-
124
- expect(stage.binding.binding.emit)
125
- .toHaveBeenNthCalledWith(index + 1, label, message)
126
- }
127
- }
128
- })
129
-
130
- it('should shutdown stage', () => {
131
- expect(stage.shutdown).toHaveBeenCalled()
132
- })
133
-
134
- it('should return results', () => {
135
- expect(ok).toStrictEqual(true)
136
- })
137
-
138
- it.each(['messages', 'operations'])('should not throw if no %s defined', async (key) => {
139
- delete suite[key]
140
-
141
- ok = await replay(suite, paths)
142
-
143
- expect(ok).toStrictEqual(true)
144
- })
145
- })
146
-
147
- const translation = (declaration) => {
148
- const find = (call) => call[0].input === declaration.input
149
- const index = mock.translate.operation.mock.calls.findIndex(find)
150
-
151
- return mock.translate.operation.mock.results[index].value
152
- }
@@ -1,24 +0,0 @@
1
- 'use strict'
2
-
3
- const { generate } = require('randomstring')
4
- const { flip } = require('@toa.io/generic')
5
-
6
- /** @type {toa.samples.Message} */
7
- const message = {
8
- title: generate(),
9
- payload: { [generate()]: generate() },
10
- input: generate(),
11
- query: { id: generate() },
12
- request: {
13
- current: {
14
- id: generate()
15
- }
16
- }
17
- }
18
-
19
- const autonomous = flip()
20
- const component = generate()
21
-
22
- exports.message = message
23
- exports.autonomous = autonomous
24
- exports.component = component
@@ -1,119 +0,0 @@
1
- 'use strict'
2
-
3
- const clone = require('clone-deep')
4
-
5
- const fixtures = require('./replay.translate.message.fixtures')
6
- const { message: translate } = require('../src/.replay/.suite/translate')
7
- const { generate } = require('randomstring')
8
-
9
- it('should be', async () => {
10
- expect(translate).toBeDefined()
11
- })
12
-
13
- /** @type {toa.samples.Message} */
14
- let declaration
15
-
16
- /** @type {toa.sampling.Message} */
17
- let message
18
-
19
- /** @type {toa.sampling.messages.Sample} */
20
- let sample
21
-
22
- beforeEach(() => {
23
- jest.clearAllMocks()
24
-
25
- declaration = clone(fixtures.message)
26
- message = translate(declaration, fixtures.autonomous, fixtures.component)
27
- sample = message.sample
28
- })
29
-
30
- it('should copy payload', async () => {
31
- expect(message.payload).toStrictEqual(declaration.payload)
32
- })
33
-
34
- it('should copy title', async () => {
35
- expect(sample.request.title).toStrictEqual(declaration.title)
36
- })
37
-
38
- it('should copy autonomous', async () => {
39
- expect(sample.request.autonomous).toStrictEqual(fixtures.autonomous)
40
- })
41
-
42
- it('should copy component', async () => {
43
- expect(sample.component).toStrictEqual(fixtures.component)
44
- })
45
-
46
- it.each(['input', 'query'])('should copy %s to request', async (key) => {
47
- const value = declaration[key]
48
-
49
- expect(sample.request.request[key]).toStrictEqual(value)
50
- })
51
-
52
- it.each(['input', 'query'])('should create request with %s', async (key) => {
53
- const value = declaration[key]
54
-
55
- delete declaration.request
56
-
57
- const { sample } = translate(declaration, fixtures.autonomous, fixtures.component)
58
-
59
- expect(sample.request.request[key]).toStrictEqual(value)
60
- })
61
-
62
- it('should keep request properties', async () => {
63
- expect(sample.request.storage.current).toMatchObject(fixtures.message.request.current)
64
- })
65
-
66
- it('should add `terminate: true` if request is not defined (and sample is autonomous)',
67
- async () => {
68
- delete declaration.request
69
-
70
- message = translate(declaration, fixtures.autonomous, fixtures.component)
71
-
72
- expect(message.sample.request.terminate).toStrictEqual(true)
73
- })
74
-
75
- it('should not create undefined keys in request', async () => {
76
- delete declaration.input
77
-
78
- message = translate(declaration, fixtures.autonomous, fixtures.component)
79
-
80
- expect('input' in message.sample.request.request).toStrictEqual(false)
81
- })
82
-
83
- it('should declare sample as authentic', async () => {
84
- expect(sample.authentic).toStrictEqual(true)
85
- })
86
-
87
- describe('validation', () => {
88
- /** @type {toa.samples.Message} */
89
- let declaration
90
-
91
- const check = () => translate(declaration, fixtures.autonomous, fixtures.component)
92
-
93
- beforeEach(() => {
94
- declaration = clone(fixtures.message)
95
- })
96
-
97
- it('should throw on schema mismatch', async () => {
98
- // noinspection JSValidateTypes
99
- declaration.title = { foo: 1 }
100
-
101
- expect(check).toThrow('must be string')
102
- })
103
-
104
- it('should throw on request schema mismatch', async () => {
105
- // noinspection JSValidateTypes
106
- declaration.request = { title: { foo: 1 } }
107
-
108
- expect(check).toThrow('must be string')
109
- })
110
-
111
- it.each([['input', 'query']])('should throw if request.%s is defined', async (key) => {
112
- expect.assertions(1)
113
-
114
- declaration[key] = { id: generate() }
115
- declaration.request = /** @type {toa.samples.Operation} */ { [key]: { id: generate() } }
116
-
117
- expect(() => check()).toThrow('/request')
118
- })
119
- })
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- const { generate } = require('randomstring')
4
-
5
- // noinspection JSCheckFunctionSignatures
6
- const operation = jest.fn((declaration) => {
7
- const { input, ...sample } = declaration
8
-
9
- return { input, sample }
10
- })
11
-
12
- // noinspection JSCheckFunctionSignatures
13
- const message = jest.fn((declaration) => generate())
14
-
15
- const translate = { operation, message }
16
-
17
- exports.translate = translate