@vida-global/core 2.4.4 → 2.4.5

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.
@@ -1,4 +1,4 @@
1
- class AppDependencies {
1
+ class DependencyRegistry {
2
2
  #dependencies = {};
3
3
  #controllerClass = null;
4
4
 
@@ -56,5 +56,6 @@ class AppDependencies {
56
56
 
57
57
 
58
58
  module.exports = {
59
- AppDependencies: new AppDependencies()
59
+ AppDependencies: new DependencyRegistry(),
60
+ DependencyRegistry
60
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vida-global/core",
3
- "version": "2.4.4",
3
+ "version": "2.4.5",
4
4
  "description": "Core libraries for supporting Vida development",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -1,4 +1,4 @@
1
- const { AppDependencies } = require('../../lib/appDependencies');
1
+ const { AppDependencies, DependencyRegistry } = require('../../lib/appDependencies');
2
2
 
3
3
 
4
4
  class FooController {}
@@ -129,3 +129,40 @@ describe('AppDependencies', () => {
129
129
  });
130
130
  });
131
131
  });
132
+
133
+
134
+ describe('DependencyRegistry', () => {
135
+ it ('builds registries that are independent of the AppDependencies singleton', () => {
136
+ const registry = new DependencyRegistry();
137
+
138
+ registry.setDependency('scopedHelper', 'scoped');
139
+
140
+ expect(registry.get('scopedHelper')).toBe('scoped');
141
+ expect(AppDependencies.get('scopedHelper')).toBeNull();
142
+ });
143
+
144
+
145
+ it ('builds registries that are independent of each other', () => {
146
+ const first = new DependencyRegistry();
147
+ const second = new DependencyRegistry();
148
+
149
+ first.setDependency('myHelper', 'one');
150
+ second.setDependency('myHelper', 'two');
151
+
152
+ expect(first.myHelper).toBe('one');
153
+ expect(second.myHelper).toBe('two');
154
+ });
155
+
156
+
157
+ it ('resets one registry without touching another', () => {
158
+ const first = new DependencyRegistry();
159
+ const second = new DependencyRegistry();
160
+ first.setDependency('myHelper', 'one');
161
+ second.setDependency('myHelper', 'two');
162
+
163
+ first.reset();
164
+
165
+ expect(first.get('myHelper')).toBeNull();
166
+ expect(second.get('myHelper')).toBe('two');
167
+ });
168
+ });