@toa.io/bridges.node 0.2.0-dev.0 → 0.2.1-dev.3

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 (42) hide show
  1. package/package.json +5 -3
  2. package/readme.md +103 -0
  3. package/src/algorithms/class.js +6 -0
  4. package/src/algorithms/factory.js +10 -0
  5. package/src/algorithms/function.js +10 -0
  6. package/src/algorithms/runner.js +50 -0
  7. package/src/context.js +68 -3
  8. package/src/define/.operations/define.js +16 -0
  9. package/src/define/.operations/extract.js +48 -0
  10. package/src/define/.operations/index.js +7 -0
  11. package/src/define/.operations/syntaxes/class.js +42 -0
  12. package/src/define/.operations/syntaxes/constants.js +4 -0
  13. package/src/define/.operations/syntaxes/factory.js +27 -0
  14. package/src/define/.operations/syntaxes/function.js +41 -0
  15. package/src/define/.operations/syntaxes/index.js +5 -0
  16. package/src/define/index.js +3 -6
  17. package/src/define/operations.js +11 -2
  18. package/src/event.js +8 -1
  19. package/src/factory.js +24 -4
  20. package/src/index.js +0 -1
  21. package/src/load.js +1 -1
  22. package/src/receiver.js +8 -1
  23. package/test/algorithms.runner.test.js +40 -0
  24. package/test/context.configuration.fixtures.js +21 -0
  25. package/test/context.configuration.test.js +23 -0
  26. package/test/context.origins.fixtures.js +16 -0
  27. package/test/context.origins.test.js +53 -0
  28. package/test/define.algorithms.test.js +36 -0
  29. package/test/define.operations.define.test.js +195 -0
  30. package/test/dummies/one/operations/cls.js +18 -0
  31. package/test/dummies/one/operations/fct.js +20 -0
  32. package/test/dummies/one/operations/fn.js +7 -0
  33. package/test/factory.algorithm.test.js +43 -0
  34. package/types/algorithms.d.ts +15 -0
  35. package/types/context.d.ts +21 -0
  36. package/types/define.d.ts +30 -0
  37. package/LICENSE +0 -22
  38. package/src/define/operations/definition.js +0 -40
  39. package/src/operation.js +0 -23
  40. package/test/operation.fixtures.js +0 -9
  41. package/test/operation.test.js +0 -39
  42. package/test/operations.definition.test.js +0 -40
@@ -1,40 +0,0 @@
1
- 'use strict'
2
-
3
- const { definition } = require('../src/define/operations/definition')
4
-
5
- it('should throw if algorithm is not async function', () => {
6
- const module = { observation: () => null }
7
- expect(() => definition(module)).toThrow(/must export async function/)
8
- })
9
-
10
- describe('type', () => {
11
- it('should return type', () => {
12
- async function observe () {}
13
-
14
- const observation = { observation: observe }
15
- const transition = { transition: async () => null }
16
-
17
- const o = definition(observation)
18
- const t = definition(transition)
19
-
20
- expect(o.type).toBe('observation')
21
- expect(t.type).toBe('transition')
22
- })
23
-
24
- it('should throw on incorrect export', () => {
25
- expect(() => definition({ _: async () => null }))
26
- .toThrow(/transition, observation or assignment/)
27
-
28
- expect(() => definition({ observation: 1 })).toThrow(/function/)
29
- })
30
- })
31
-
32
- describe('subject', () => {
33
- it('should return subject', () => {
34
- const entity = { observation: async (input, entity) => Object.assign(entity, input) }
35
- const set = { observation: async (input, set) => Object.assign(set, input) }
36
-
37
- expect(definition(entity)).toMatchObject({ subject: 'entity' })
38
- expect(definition(set)).toMatchObject({ subject: 'set' })
39
- })
40
- })