1 |
|
2 |
|
3 | const chai = require('chai')
|
4 | chai.use(require('dirty-chai'))
|
5 | const expect = chai.expect
|
6 | const path = require('path')
|
7 |
|
8 | const loadDir = require('../lib/boot/load/tymly-loader/load-dir')
|
9 |
|
10 | describe('loadDir loader test', () => {
|
11 | const testDir = path.resolve(
|
12 | __dirname,
|
13 | './fixtures/loader'
|
14 | )
|
15 |
|
16 | it('load a plain blueprint dir', () => {
|
17 | const components = { }
|
18 | const tymlyRefs = { }
|
19 |
|
20 | loadDir(
|
21 | path.resolve(testDir, 'cats-blueprint'),
|
22 | components,
|
23 | tymlyRefs,
|
24 | {
|
25 | quiet: true,
|
26 | expectModule: false,
|
27 | expectedMetaFilename: 'blueprint.json',
|
28 | mandatoryMetaKeys: ['name', 'version', 'namespace']
|
29 | }
|
30 | )
|
31 |
|
32 | expect(components.categories).to.not.be.null()
|
33 | expect(components.registryKeys).to.not.be.null()
|
34 | expect(components.stateMachines).to.not.be.null()
|
35 | expect(components.templateRoles).to.not.be.null()
|
36 | expect(tymlyRefs).to.eql({})
|
37 | })
|
38 |
|
39 | it('load a blueprint with refs', () => {
|
40 | const components = { }
|
41 | const tymlyRefs = { }
|
42 |
|
43 | loadDir(
|
44 | path.resolve(testDir, 'cats-blueprint-with-ref'),
|
45 | components,
|
46 | tymlyRefs,
|
47 | {
|
48 | quiet: true,
|
49 | expectModule: false,
|
50 | expectedMetaFilename: 'blueprint.json',
|
51 | mandatoryMetaKeys: ['name', 'version', 'namespace']
|
52 | }
|
53 | )
|
54 |
|
55 | expect(components.categories).to.not.be.null()
|
56 | expect(components.registryKeys).to.not.be.null()
|
57 | expect(components.stateMachines).to.not.be.null()
|
58 | expect(components.templateRoles).to.not.be.null()
|
59 | expect(tymlyRefs).to.eql({
|
60 | stateMachines: {
|
61 | tymlyTest_aDayInTheLife: [{
|
62 | path: '$.States.Sitting',
|
63 | ref: 'task://sitting'
|
64 | }]
|
65 | }
|
66 | })
|
67 | })
|
68 | })
|