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

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 (122) hide show
  1. package/package.json +10 -11
  2. package/readme.md +0 -2
  3. package/stage/src/component.js +0 -5
  4. package/stage/src/composition.js +0 -4
  5. package/stage/src/index.js +0 -2
  6. package/stage/src/shutdown.js +0 -2
  7. package/stage/test/composition.test.js +0 -11
  8. package/stage/test/shutdown.test.js +1 -10
  9. package/stage/types/index.d.ts +0 -2
  10. package/example/components/echo/samples/get.yaml +0 -12
  11. package/example/components/echo/samples/signal.yaml +0 -4
  12. package/example/components/math.calculations/samples/add.yaml +0 -10
  13. package/example/components/math.calculations/samples/assets/ab.yaml +0 -2
  14. package/example/components/math.calculations/samples/increment.yaml +0 -27
  15. package/example/components/math.proxy/samples/add.yaml +0 -11
  16. package/example/components/tea.pots/samples/same.yaml +0 -8
  17. package/example/components/tea.pots/samples/transit.yaml +0 -43
  18. package/example/components/web/samples/get.yaml +0 -8
  19. package/example/samples/math.proxy.add.yaml +0 -5
  20. package/example/samples/messages/store.orders.created.yaml +0 -8
  21. package/samples/docs/sampling-dark.jpg +0 -0
  22. package/samples/docs/sampling-light.jpg +0 -0
  23. package/samples/notes.md +0 -12
  24. package/samples/package.json +0 -5
  25. package/samples/readme.md +0 -131
  26. package/samples/src/.replay/.suite/component.js +0 -20
  27. package/samples/src/.replay/.suite/index.js +0 -7
  28. package/samples/src/.replay/.suite/messages.js +0 -39
  29. package/samples/src/.replay/.suite/operation.js +0 -28
  30. package/samples/src/.replay/.suite/operations.js +0 -20
  31. package/samples/src/.replay/.suite/translate/.message/index.js +0 -5
  32. package/samples/src/.replay/.suite/translate/.message/request.js +0 -31
  33. package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.js +0 -20
  34. package/samples/src/.replay/.suite/translate/.operation/.prepare/cast.test.js +0 -94
  35. package/samples/src/.replay/.suite/translate/.operation/.prepare/expand.js +0 -14
  36. package/samples/src/.replay/.suite/translate/.operation/.prepare/index.js +0 -7
  37. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/.aspect.js +0 -26
  38. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/configuration.js +0 -5
  39. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/http.js +0 -5
  40. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/index.js +0 -9
  41. package/samples/src/.replay/.suite/translate/.operation/.prepare/shortcuts/state.js +0 -5
  42. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/async.js +0 -3
  43. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/cast.js +0 -26
  44. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/index.js +0 -5
  45. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/map.js +0 -3
  46. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/set.js +0 -3
  47. package/samples/src/.replay/.suite/translate/.operation/.prepare/types/sync.js +0 -3
  48. package/samples/src/.replay/.suite/translate/.operation/calls.js +0 -49
  49. package/samples/src/.replay/.suite/translate/.operation/cleanup.js +0 -16
  50. package/samples/src/.replay/.suite/translate/.operation/events.js +0 -16
  51. package/samples/src/.replay/.suite/translate/.operation/index.js +0 -11
  52. package/samples/src/.replay/.suite/translate/.operation/prepare.js +0 -14
  53. package/samples/src/.replay/.suite/translate/index.js +0 -7
  54. package/samples/src/.replay/.suite/translate/message.js +0 -26
  55. package/samples/src/.replay/.suite/translate/operation.js +0 -47
  56. package/samples/src/.replay/.suite/translate/schemas/index.js +0 -7
  57. package/samples/src/.replay/.suite/translate/schemas/message.cos.yaml +0 -10
  58. package/samples/src/.replay/.suite/translate/schemas/operation.cos.yaml +0 -23
  59. package/samples/src/.replay/index.js +0 -7
  60. package/samples/src/.replay/stage.js +0 -60
  61. package/samples/src/.replay/suite.js +0 -23
  62. package/samples/src/.replay/test.js +0 -19
  63. package/samples/src/components.js +0 -13
  64. package/samples/src/context.js +0 -23
  65. package/samples/src/index.js +0 -9
  66. package/samples/src/replay.js +0 -16
  67. package/samples/src/suite/.read/filter.js +0 -15
  68. package/samples/src/suite/.read/index.js +0 -7
  69. package/samples/src/suite/.read/messages.js +0 -40
  70. package/samples/src/suite/.read/operations.js +0 -51
  71. package/samples/src/suite/.read/parse.js +0 -20
  72. package/samples/src/suite/components.js +0 -31
  73. package/samples/src/suite/context.js +0 -20
  74. package/samples/src/suite/index.js +0 -7
  75. package/samples/test/components.test.js +0 -42
  76. package/samples/test/context/components/dummy/manifest.toa.yaml +0 -2
  77. package/samples/test/context/components/dummy/samples/do.yaml +0 -11
  78. package/samples/test/context/components/dummy/samples/dummies.dummy.do.yaml +0 -11
  79. package/samples/test/context/components/dummy/samples/dummies.dummy.undo.yaml +0 -7
  80. package/samples/test/context/components/dummy/samples/messages/somewhere.something.happened.yaml +0 -6
  81. package/samples/test/context/components/pot/manifest.toa.yaml +0 -2
  82. package/samples/test/context/components/pot/samples/do.yaml +0 -11
  83. package/samples/test/context/components/pot/samples/messages/somewhere.something.happened.yaml +0 -6
  84. package/samples/test/context/context.toa.yaml +0 -3
  85. package/samples/test/context/samples/dummies.dummy.observe.yaml +0 -6
  86. package/samples/test/context/samples/dummies.dummy.transit.yaml +0 -10
  87. package/samples/test/context/samples/messages/somewhere.something.happened.yaml +0 -6
  88. package/samples/test/context.fixtures.js +0 -8
  89. package/samples/test/context.test.js +0 -82
  90. package/samples/test/replay.mock.js +0 -7
  91. package/samples/test/replay.test.js +0 -152
  92. package/samples/test/replay.translate.message.fixtures.js +0 -24
  93. package/samples/test/replay.translate.message.test.js +0 -119
  94. package/samples/test/replay.translate.mock.js +0 -17
  95. package/samples/test/replay.translate.operation.fixtures.js +0 -107
  96. package/samples/test/replay.translate.operation.test.js +0 -68
  97. package/samples/test/stage.mock.js +0 -30
  98. package/samples/test/suite.components.test.js +0 -122
  99. package/samples/test/suite.context.test.js +0 -79
  100. package/samples/test/suite.mock.js +0 -10
  101. package/samples/types/index.d.ts +0 -8
  102. package/samples/types/message.d.ts +0 -24
  103. package/samples/types/operation.d.ts +0 -36
  104. package/samples/types/replay.d.ts +0 -13
  105. package/samples/types/suite.d.ts +0 -31
  106. package/stage/src/binding/binding.js +0 -50
  107. package/stage/src/binding/consumer.js +0 -30
  108. package/stage/src/binding/emitter.js +0 -26
  109. package/stage/src/binding/factory.js +0 -49
  110. package/stage/src/binding/index.js +0 -10
  111. package/stage/src/binding/label.js +0 -12
  112. package/stage/src/binding/producer.js +0 -43
  113. package/stage/src/binding/receiver.js +0 -34
  114. package/stage/test/binding/binding.test.js +0 -15
  115. package/stage/test/binding/consumer.test.js +0 -52
  116. package/stage/test/binding/emitter.test.js +0 -54
  117. package/stage/test/binding/producer.fixtures.js +0 -10
  118. package/stage/test/binding/producer.test.js +0 -49
  119. package/stage/test/binding/receiver.fixtures.js +0 -7
  120. package/stage/test/binding/receiver.test.js +0 -54
  121. package/stage/test/binding.mock.js +0 -8
  122. package/stage/types/binding.d.ts +0 -20
@@ -1,40 +0,0 @@
1
- 'use strict'
2
-
3
- const { join, basename } = require('node:path')
4
- const { file: { glob } } = require('@toa.io/filesystem')
5
- const yaml = require('@toa.io/yaml')
6
-
7
- const { filter } = require('./filter')
8
-
9
- /**
10
- * @param {string} path
11
- * @param {toa.samples.suite.Options} options
12
- * @returns {Promise<toa.samples.messages.Set>}
13
- */
14
- const messages = async (path, options) => {
15
- /** @type {toa.samples.messages.Set} */
16
- const messages = {}
17
-
18
- const pattern = join(path, DIRECTORY, PATTERN)
19
- const files = await glob(pattern)
20
-
21
- for (const file of files) {
22
- const label = basename(file, EXTENSION)
23
-
24
- let samples = /** @type {toa.samples.Message[]} */ await yaml.load.all(file)
25
-
26
- if (options.id !== undefined) samples.forEach((sample) => (sample.component = options.id))
27
- if (options.component !== undefined) samples = samples.filter((sample) => sample.component === options.component)
28
- if (options.title !== undefined) samples = filter(samples, options.title)
29
-
30
- messages[label] = samples
31
- }
32
-
33
- return messages
34
- }
35
-
36
- const DIRECTORY = 'samples/messages'
37
- const EXTENSION = '.yaml'
38
- const PATTERN = '*' + EXTENSION
39
-
40
- exports.messages = messages
@@ -1,51 +0,0 @@
1
- 'use strict'
2
-
3
- const { basename, join } = require('node:path')
4
- const { file: { glob } } = require('@toa.io/filesystem')
5
- const { merge } = require('@toa.io/generic')
6
- const yaml = require('@toa.io/yaml')
7
-
8
- const { parse } = require('./parse')
9
- const { filter } = require('./filter')
10
-
11
- /**
12
- * @param {string} path
13
- * @param {toa.samples.suite.Options} options
14
- * @returns {Promise<toa.samples.suite.Operations>}
15
- */
16
- const operations = async (path, options) => {
17
- /** @type {toa.samples.suite.Operations} */
18
- const operations = {}
19
-
20
- const pattern = join(path, DIRECTORY, PATTERN)
21
- const files = await glob(pattern)
22
-
23
- for (const file of files) {
24
- const name = basename(file, EXTENSION)
25
- const [component, operation] = parse(name, options.id)
26
-
27
- if (options.component !== undefined && component !== options.component) continue
28
- if (options.operation !== undefined && operation !== options.operation) continue
29
-
30
- let samples = /** @type {toa.samples.Operation[]} */ await yaml.load.all(file)
31
-
32
- if (options.title !== undefined) samples = filter(samples, options.title)
33
- if (samples.length === 0) continue
34
-
35
- if (operations[component] === undefined) operations[component] = {}
36
-
37
- /** @type {toa.samples.operations.Set} */
38
- const set = operations[component]
39
-
40
- if (set[operation] === undefined) set[operation] = samples
41
- else set[operation] = /** @type {toa.samples.Operation[]} */ merge(set[operation], samples)
42
- }
43
-
44
- return operations
45
- }
46
-
47
- const DIRECTORY = 'samples'
48
- const EXTENSION = '.yaml'
49
- const PATTERN = '*' + EXTENSION
50
-
51
- exports.operations = operations
@@ -1,20 +0,0 @@
1
- 'use strict'
2
-
3
- /**
4
- * @param {string} name
5
- * @param {string} [def]
6
- * @returns {[string, string]}
7
- */
8
- const parse = (name, def) => {
9
- const parts = name.split('.')
10
- const [endpoint, component, namespace] = parts.reverse()
11
- const id = namespace === undefined ? def : namespace + '.' + component
12
-
13
- if (id !== undefined && def !== undefined && id !== def) {
14
- throw new Error(`Component id mismatch: '${id}' expected, '${component}' given`)
15
- }
16
-
17
- return [id, endpoint]
18
- }
19
-
20
- exports.parse = parse
@@ -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