|
1 |
| -const { assert } = require('chai'); |
2 |
| -const { LoggerFactory } = require('@alt-javascript/logger'); |
3 |
| -const { EphemeralConfig } = require('@alt-javascript/config'); |
4 |
| -const { v4: uuidv4 } = require('uuid'); |
5 |
| -const { Application, ApplicationContext } = require('..'); |
6 |
| -const { Context, Component } = require('../context'); |
7 |
| -const SimpleClass = require('./service/SimpleClass'); |
8 |
| - |
9 |
| -const logger = LoggerFactory.getLogger('@alt-javascript/contexts/test/ApplicationContext_spec'); |
10 |
| - |
11 |
| -before(async () => { |
12 |
| - logger.verbose('before spec setup started'); |
13 |
| - // .. |
14 |
| - logger.verbose('before spec setup completed'); |
15 |
| -}); |
16 |
| - |
17 |
| -beforeEach(async () => { |
18 |
| - logger.verbose('before each setup started'); |
19 |
| - // .. |
20 |
| - logger.verbose('before each setup completed'); |
21 |
| -}); |
22 |
| - |
23 |
| -after(async () => { |
24 |
| - logger.verbose('after teardown started'); |
25 |
| - // ... |
26 |
| - logger.verbose('after teardown completed'); |
27 |
| -}); |
28 |
| - |
29 |
| -beforeEach(async () => { |
30 |
| - logger.verbose('before each setup started'); |
31 |
| - // .. |
32 |
| - logger.verbose('before each setup completed'); |
33 |
| -}); |
34 |
| - |
35 |
| -describe('Singletons Specification', () => { |
36 |
| - it('ApplicationContext accepts Context array', () => { |
37 |
| - const context = new Context([new Component(SimpleClass)]); |
38 |
| - |
39 |
| - const applicationContext = Application.run([context]); |
40 |
| - |
41 |
| - const simpleClass = applicationContext.get('simpleClass'); |
42 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
43 |
| - }); |
44 |
| - |
45 |
| - it('ApplicationContext accepts Context object', () => { |
46 |
| - const context = new Context(new Component(SimpleClass)); |
47 |
| - |
48 |
| - const applicationContext = Application.run(context); |
49 |
| - |
50 |
| - const simpleClass = applicationContext.get('simpleClass'); |
51 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
52 |
| - }); |
53 |
| - |
54 |
| - it('ApplicationContext accepts Component object', () => { |
55 |
| - const context = new Component(SimpleClass); |
56 |
| - |
57 |
| - const applicationContext = Application.run(context); |
58 |
| - |
59 |
| - const simpleClass = applicationContext.get('simpleClass'); |
60 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
61 |
| - }); |
62 |
| - |
63 |
| - it('ApplicationContext accepts plain old class', () => { |
64 |
| - const context = SimpleClass; |
65 |
| - |
66 |
| - const applicationContext = Application.run(context); |
67 |
| - |
68 |
| - const simpleClass = applicationContext.get('simpleClass'); |
69 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
70 |
| - }); |
71 |
| - |
72 |
| - it('ApplicationContext accepts plain old object', () => { |
73 |
| - const context = { name: 'SimpleClass', uuid: uuidv4() }; |
74 |
| - |
75 |
| - const applicationContext = Application.run(context); |
76 |
| - |
77 |
| - const simpleClass = applicationContext.get('simpleClass'); |
78 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
79 |
| - }); |
80 |
| - |
81 |
| - it('ApplicationContext accepts plain old object, with require', () => { |
82 |
| - const context = { name: 'SimpleClass', require: './test/service/SimpleClass' }; |
83 |
| - |
84 |
| - const applicationContext = Application.run(context); |
85 |
| - |
86 |
| - const simpleClass = applicationContext.get('simpleClass'); |
87 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
88 |
| - assert.exists(simpleClass.uuid, 'simpleClass.uuid exists'); |
89 |
| - }); |
90 |
| - |
91 |
| - it('ApplicationContext accepts config context', () => { |
92 |
| - const ephemeralConfig = new EphemeralConfig( |
93 |
| - { |
94 |
| - context: { |
95 |
| - SimpleClass: { |
96 |
| - require: './test/service/SimpleClass', |
97 |
| - }, |
98 |
| - }, |
99 |
| - }, |
100 |
| - ); |
101 |
| - |
102 |
| - const applicationContext = Application.run({ config: ephemeralConfig }); |
103 |
| - |
104 |
| - const simpleClass = applicationContext.get('simpleClass'); |
105 |
| - assert.exists(simpleClass, 'simpleClass exists'); |
106 |
| - assert.exists(simpleClass.uuid, 'simpleClass.uuid exists'); |
107 |
| - }); |
108 |
| -}); |
| 1 | +// const { assert } = require('chai'); |
| 2 | +// const { LoggerFactory } = require('@alt-javascript/logger'); |
| 3 | +// const { EphemeralConfig } = require('@alt-javascript/config'); |
| 4 | +// const { v4: uuidv4 } = require('uuid'); |
| 5 | +// const { Application, ApplicationContext } = require('..'); |
| 6 | +// const { Context, Component } = require('../context'); |
| 7 | +// const SimpleClass = require('./service/SimpleClass'); |
| 8 | +// |
| 9 | +// const logger = LoggerFactory.getLogger('@alt-javascript/contexts/test/ApplicationContext_spec'); |
| 10 | +// |
| 11 | +// before(async () => { |
| 12 | +// logger.verbose('before spec setup started'); |
| 13 | +// // .. |
| 14 | +// logger.verbose('before spec setup completed'); |
| 15 | +// }); |
| 16 | +// |
| 17 | +// beforeEach(async () => { |
| 18 | +// logger.verbose('before each setup started'); |
| 19 | +// // .. |
| 20 | +// logger.verbose('before each setup completed'); |
| 21 | +// }); |
| 22 | +// |
| 23 | +// after(async () => { |
| 24 | +// logger.verbose('after teardown started'); |
| 25 | +// // ... |
| 26 | +// logger.verbose('after teardown completed'); |
| 27 | +// }); |
| 28 | +// |
| 29 | +// beforeEach(async () => { |
| 30 | +// logger.verbose('before each setup started'); |
| 31 | +// // .. |
| 32 | +// logger.verbose('before each setup completed'); |
| 33 | +// }); |
| 34 | +// |
| 35 | +// describe('Singletons Specification', () => { |
| 36 | +// it('ApplicationContext accepts Context array', () => { |
| 37 | +// const context = new Context([new Component(SimpleClass)]); |
| 38 | +// |
| 39 | +// const applicationContext = Application.run([context]); |
| 40 | +// |
| 41 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 42 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 43 | +// }); |
| 44 | +// |
| 45 | +// it('ApplicationContext accepts Context object', () => { |
| 46 | +// const context = new Context(new Component(SimpleClass)); |
| 47 | +// |
| 48 | +// const applicationContext = Application.run(context); |
| 49 | +// |
| 50 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 51 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 52 | +// }); |
| 53 | +// |
| 54 | +// it('ApplicationContext accepts Component object', () => { |
| 55 | +// const context = new Component(SimpleClass); |
| 56 | +// |
| 57 | +// const applicationContext = Application.run(context); |
| 58 | +// |
| 59 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 60 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 61 | +// }); |
| 62 | +// |
| 63 | +// it('ApplicationContext accepts plain old class', () => { |
| 64 | +// const context = SimpleClass; |
| 65 | +// |
| 66 | +// const applicationContext = Application.run(context); |
| 67 | +// |
| 68 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 69 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 70 | +// }); |
| 71 | +// |
| 72 | +// it('ApplicationContext accepts plain old object', () => { |
| 73 | +// const context = { name: 'SimpleClass', uuid: uuidv4() }; |
| 74 | +// |
| 75 | +// const applicationContext = Application.run(context); |
| 76 | +// |
| 77 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 78 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 79 | +// }); |
| 80 | +// |
| 81 | +// it('ApplicationContext accepts plain old object, with require', () => { |
| 82 | +// const context = { name: 'SimpleClass', require: './test/service/SimpleClass' }; |
| 83 | +// |
| 84 | +// const applicationContext = Application.run(context); |
| 85 | +// |
| 86 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 87 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 88 | +// assert.exists(simpleClass.uuid, 'simpleClass.uuid exists'); |
| 89 | +// }); |
| 90 | +// |
| 91 | +// it('ApplicationContext accepts config context', () => { |
| 92 | +// const ephemeralConfig = new EphemeralConfig( |
| 93 | +// { |
| 94 | +// context: { |
| 95 | +// SimpleClass: { |
| 96 | +// require: './test/service/SimpleClass', |
| 97 | +// }, |
| 98 | +// }, |
| 99 | +// }, |
| 100 | +// ); |
| 101 | +// |
| 102 | +// const applicationContext = Application.run({ config: ephemeralConfig }); |
| 103 | +// |
| 104 | +// const simpleClass = applicationContext.get('simpleClass'); |
| 105 | +// assert.exists(simpleClass, 'simpleClass exists'); |
| 106 | +// assert.exists(simpleClass.uuid, 'simpleClass.uuid exists'); |
| 107 | +// }); |
| 108 | +// }); |
0 commit comments