fable-serviceproviderbase 3.0.3 → 3.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fable-serviceproviderbase",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Simple base classes for fable services.",
5
5
  "main": "source/Fable-ServiceProviderBase.js",
6
6
  "scripts": {
@@ -42,7 +42,7 @@
42
42
  "homepage": "https://github.com/stevenvelozo/fable-serviceproviderbase",
43
43
  "devDependencies": {
44
44
  "chai": "4.3.7",
45
- "fable": "^3.0.29",
45
+ "fable": "^3.0.46",
46
46
  "mocha": "10.2.0",
47
47
  "nyc": "^15.1.0"
48
48
  }
@@ -9,16 +9,30 @@ class FableServiceProviderBase
9
9
  {
10
10
  this.fable = pFable;
11
11
 
12
- this.options = (typeof(pOptions) === 'object') ? pOptions : {};
13
-
14
- this.serviceType = 'Unknown';
15
-
16
- this.UUID = pFable.getUUID();
17
-
18
- this.Hash = (typeof(pServiceHash) === 'string') ? pServiceHash : `${this.UUID}`;
12
+ this.options = (typeof(pOptions) === 'object') ? pOptions
13
+ : ((typeof(pFable) === 'object') && !pFable.isFable) ? pFable
14
+ : {};
15
+
16
+ this.serviceType = 'Unknown';
17
+
18
+ if (typeof(pFable.getUUID) == 'function')
19
+ {
20
+ this.UUID = pFable.getUUID();
21
+ }
22
+ else
23
+ {
24
+ this.UUID = `NoFABLESVC-${Math.floor((Math.random() * (99999 - 10000)) + 10000)}`
25
+ }
26
+
27
+ this.Hash = (typeof(pServiceHash) === 'string') ? pServiceHash : `${this.UUID}`;
28
+
29
+ // Pull back a few things
30
+ this.log = this.fable.log;
31
+ this.services = this.fable.services;
32
+ this.defaultServices = this.fable.defaultServices;
19
33
  }
20
34
 
21
- static isFableService = true;
35
+ static isFableService = true;
22
36
  }
23
37
 
24
38
  module.exports = FableServiceProviderBase;
@@ -88,7 +88,7 @@ suite
88
88
  function()
89
89
  {
90
90
  testFable = new libFable();
91
-
91
+
92
92
  let tmpSimpleService = new SimpleService(testFable, {SomeOption: true});
93
93
 
94
94
  tmpSimpleService.doSomething();
@@ -115,10 +115,13 @@ suite
115
115
  {
116
116
  testFable = new libFable();
117
117
  testFable.serviceManager.addServiceType('SimpleService', SimpleService);
118
- testFable.serviceManager.instantiateServiceProvider('SimpleService', {SomeOption: true}, 'SimpleService-123');
118
+ let tmpSimpleService = testFable.serviceManager.instantiateServiceProvider('SimpleService', {SomeOption: true}, 'SimpleService-123');
119
119
 
120
120
  Expect(testFable.serviceManager.services['SimpleService']['SimpleService-123']).to.be.an('object');
121
121
 
122
+ // The passed-in magic stuff should work too.
123
+ tmpSimpleService.log.info(`There were almost ${tmpSimpleService.defaultServices.DataFormat.formatterDollars(9821229.37)} dollars just lying here!`);
124
+
122
125
  Expect(testFable.serviceManager.defaultServices['SimpleService']).to.be.an('object');
123
126
 
124
127
  testFable.serviceManager.defaultServices.SimpleService.doSomething();
@@ -241,6 +244,18 @@ suite
241
244
  }
242
245
  )
243
246
 
247
+ test
248
+ (
249
+ 'Construct a service without a fable at all',
250
+ function()
251
+ {
252
+ let tmpService = new SimpleService({Setting:'Something'});
253
+
254
+ Expect(tmpService.options.Setting).to.equal('Something');
255
+ Expect(tmpService.UUID).to.be.a('string');
256
+ }
257
+ )
258
+
244
259
  test
245
260
  (
246
261
  'Attempt to change the default service provider to a nonexistant provider',