fable 3.0.62 → 3.0.63
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 +3 -3
- package/source/Fable-ServiceManager.js +13 -13
- package/source/Fable.js +1 -1
- package/source/services/Fable-Service-DataGeneration.js +1 -1
- package/source/services/Fable-Service-MetaTemplate.js +1 -1
- package/source/services/Fable-Service-RestClient.js +1 -1
- package/test/DataFormat-StringDateFormatting_tests.js +4 -4
- package/test/DataFormat-StringManipulation_tests.js +12 -12
- package/test/DataFormat-StringNumberFormatting_tests.js +3 -3
- package/test/DataFormat-StringTokenization_tests.js +5 -5
- package/test/FableOperation_tests.js +5 -5
- package/test/FableServiceManager_tests.js +27 -27
- package/test/Fable_tests.js +1 -1
- package/test/Utility_tests.js +33 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fable",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.63",
|
|
4
4
|
"description": "An entity behavior management and API bundling library.",
|
|
5
5
|
"main": "source/Fable.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/stevenvelozo/fable",
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"quackage": "^1.0.
|
|
52
|
+
"quackage": "^1.0.13"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"async.eachlimit": "^0.5.2",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"cookie": "^0.5.0",
|
|
59
59
|
"data-arithmatic": "^1.0.7",
|
|
60
60
|
"fable-log": "^3.0.10",
|
|
61
|
-
"fable-serviceproviderbase": "^3.0.
|
|
61
|
+
"fable-serviceproviderbase": "^3.0.6",
|
|
62
62
|
"fable-settings": "^3.0.6",
|
|
63
63
|
"fable-uuid": "^3.0.5",
|
|
64
64
|
"manyfest": "^1.0.24",
|
|
@@ -16,10 +16,10 @@ class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
|
16
16
|
this.serviceTypes = [];
|
|
17
17
|
|
|
18
18
|
// A map of instantiated services
|
|
19
|
-
this.
|
|
19
|
+
this.serviceMap = {};
|
|
20
20
|
|
|
21
21
|
// A map of the default instantiated service by type
|
|
22
|
-
this.
|
|
22
|
+
this.services = {};
|
|
23
23
|
|
|
24
24
|
// A map of class constructors for services
|
|
25
25
|
this.serviceClasses = {};
|
|
@@ -34,7 +34,7 @@ class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
|
34
34
|
this.serviceTypes.push(pServiceType);
|
|
35
35
|
|
|
36
36
|
// Add the container for instantiated services to go in
|
|
37
|
-
this.
|
|
37
|
+
this.serviceMap[pServiceType] = {};
|
|
38
38
|
|
|
39
39
|
// Using the static member of the class is a much more reliable way to check if it is a service class than instanceof
|
|
40
40
|
if ((typeof(pServiceClass) == 'function') && (pServiceClass.isFableService))
|
|
@@ -69,10 +69,10 @@ class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
// Add the service to the service map
|
|
72
|
-
this.
|
|
72
|
+
this.serviceMap[pServiceType][tmpService.Hash] = tmpService;
|
|
73
73
|
|
|
74
74
|
// If this is the first service of this type, make it the default
|
|
75
|
-
if (!this.
|
|
75
|
+
if (!this.services.hasOwnProperty(pServiceType))
|
|
76
76
|
{
|
|
77
77
|
this.setDefaultServiceInstantiation(pServiceType, tmpService.Hash)
|
|
78
78
|
}
|
|
@@ -87,10 +87,10 @@ class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
|
87
87
|
let tmpService = this.instantiateServiceProviderWithoutRegistration(pServiceType, pOptions, pCustomServiceHash);
|
|
88
88
|
|
|
89
89
|
// Add the service to the service map
|
|
90
|
-
this.
|
|
90
|
+
this.serviceMap[pServiceType][tmpService.Hash] = tmpService;
|
|
91
91
|
|
|
92
92
|
// If this is the first service of this type, make it the default
|
|
93
|
-
if (!this.
|
|
93
|
+
if (!this.services.hasOwnProperty(pServiceType))
|
|
94
94
|
{
|
|
95
95
|
this.setDefaultServiceInstantiation(pServiceType, tmpService.Hash)
|
|
96
96
|
}
|
|
@@ -119,17 +119,17 @@ class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
|
119
119
|
// The service should already be instantiated, so just connect it to fable
|
|
120
120
|
pServiceInstance.connectFable(this.fable);
|
|
121
121
|
|
|
122
|
-
if (!this.
|
|
122
|
+
if (!this.serviceMap.hasOwnProperty(tmpServiceType))
|
|
123
123
|
{
|
|
124
124
|
// If the core service hasn't registered itself yet, create the service container for it.
|
|
125
125
|
// This means you couldn't register another with this type unless it was later registered with a constructor class.
|
|
126
126
|
this.services[tmpServiceType] = {};
|
|
127
127
|
}
|
|
128
128
|
// Add the service to the service map
|
|
129
|
-
this.
|
|
129
|
+
this.serviceMap[tmpServiceType][tmpServiceHash] = pServiceInstance;
|
|
130
130
|
|
|
131
131
|
// If this is the first service of this type, make it the default
|
|
132
|
-
if (!this.
|
|
132
|
+
if (!this.services.hasOwnProperty(tmpServiceType))
|
|
133
133
|
{
|
|
134
134
|
this.setDefaultServiceInstantiation(tmpServiceType, tmpServiceHash)
|
|
135
135
|
}
|
|
@@ -139,10 +139,10 @@ class FableService extends libFableServiceBase.CoreServiceProviderBase
|
|
|
139
139
|
|
|
140
140
|
setDefaultServiceInstantiation(pServiceType, pServiceHash)
|
|
141
141
|
{
|
|
142
|
-
if (this.
|
|
142
|
+
if (this.serviceMap[pServiceType].hasOwnProperty(pServiceHash))
|
|
143
143
|
{
|
|
144
|
-
this.fable[pServiceType] = this.
|
|
145
|
-
this.
|
|
144
|
+
this.fable[pServiceType] = this.serviceMap[pServiceType][pServiceHash];
|
|
145
|
+
this.services[pServiceType] = this.serviceMap[pServiceType][pServiceHash];
|
|
146
146
|
return true;
|
|
147
147
|
}
|
|
148
148
|
|
package/source/Fable.js
CHANGED
|
@@ -33,7 +33,7 @@ class FableServiceDataGeneration extends libFableServiceBase
|
|
|
33
33
|
let tmpLength = (typeof(pLength) === 'undefined') ? 10 : pLength;
|
|
34
34
|
let tmpMaxNumber = (typeof(pMaxNumber) === 'undefined') ? ((10 ** tmpLength) - 1) : pMaxNumber;
|
|
35
35
|
|
|
36
|
-
return this.
|
|
36
|
+
return this.services.DataFormat.stringPadStart(this.randomIntegerUpTo(tmpMaxNumber), pLength, '0');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
|
|
@@ -20,7 +20,7 @@ class FableServiceMetaTemplate extends libFableServiceBase
|
|
|
20
20
|
this.WordTree = new libWordTree();
|
|
21
21
|
|
|
22
22
|
// In order to allow asynchronous template processing we need to use the async.eachLimit function
|
|
23
|
-
this.StringParser = new libStringParser(this.fable.
|
|
23
|
+
this.StringParser = new libStringParser(this.fable.services.Utility.eachLimit);
|
|
24
24
|
|
|
25
25
|
this.ParseTree = this.WordTree.ParseTree;
|
|
26
26
|
}
|
|
@@ -29,7 +29,7 @@ suite
|
|
|
29
29
|
(fTestComplete)=>
|
|
30
30
|
{
|
|
31
31
|
let testFable = new libFable({LogStreams: false});
|
|
32
|
-
let _DataFormat = testFable.
|
|
32
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
33
33
|
Expect(_DataFormat
|
|
34
34
|
.formatTimeSpan(1000))
|
|
35
35
|
.to.equal('00:00:01.000');
|
|
@@ -51,7 +51,7 @@ suite
|
|
|
51
51
|
(fTestComplete) =>
|
|
52
52
|
{
|
|
53
53
|
let testFable = new libFable({LogStreams: false});
|
|
54
|
-
let _DataFormat = testFable.
|
|
54
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
55
55
|
Expect(_DataFormat
|
|
56
56
|
.formatTimeDelta(1000, 2000))
|
|
57
57
|
.to.equal('00:00:01.000');
|
|
@@ -73,7 +73,7 @@ suite
|
|
|
73
73
|
(fTestComplete) =>
|
|
74
74
|
{
|
|
75
75
|
let testFable = new libFable();
|
|
76
|
-
let _DataFormat = testFable.
|
|
76
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
77
77
|
Expect(_DataFormat
|
|
78
78
|
.getMonthFromDate(new Date('10/20/1988')))
|
|
79
79
|
.to.equal('October');
|
|
@@ -96,7 +96,7 @@ suite
|
|
|
96
96
|
(fTestComplete) =>
|
|
97
97
|
{
|
|
98
98
|
let testFable = new libFable();
|
|
99
|
-
let _DataFormat = testFable.
|
|
99
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
100
100
|
Expect(_DataFormat
|
|
101
101
|
.formatSortableStringFromDate(new Date('10/20/1986')))
|
|
102
102
|
.to.equal('19860920');
|
|
@@ -29,7 +29,7 @@ suite
|
|
|
29
29
|
(fTestComplete)=>
|
|
30
30
|
{
|
|
31
31
|
let testFable = new libFable({LogStreams: false});
|
|
32
|
-
let _DataFormat = testFable.
|
|
32
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
33
33
|
Expect(_DataFormat
|
|
34
34
|
.stringReverse('Dogs'))
|
|
35
35
|
.to.equal('sgoD');
|
|
@@ -45,7 +45,7 @@ suite
|
|
|
45
45
|
(fTestComplete)=>
|
|
46
46
|
{
|
|
47
47
|
let testFable = new libFable({LogStreams: false});
|
|
48
|
-
let _DataFormat = testFable.
|
|
48
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
49
49
|
Expect(_DataFormat
|
|
50
50
|
.insecureStringHash('Dogs'))
|
|
51
51
|
.to.equal('HSH2135767');
|
|
@@ -68,7 +68,7 @@ suite
|
|
|
68
68
|
(fTestComplete)=>
|
|
69
69
|
{
|
|
70
70
|
let testFable = new libFable({LogStreams: false});
|
|
71
|
-
let _DataFormat = testFable.
|
|
71
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
72
72
|
Expect(_DataFormat.cleanNonAlphaCharacters('Dogs'))
|
|
73
73
|
.to.equal('Dogs');
|
|
74
74
|
Expect(_DataFormat.cleanNonAlphaCharacters('Dogs1'))
|
|
@@ -84,7 +84,7 @@ suite
|
|
|
84
84
|
(fTestComplete)=>
|
|
85
85
|
{
|
|
86
86
|
let testFable = new libFable({LogStreams: false});
|
|
87
|
-
let _DataFormat = testFable.
|
|
87
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
88
88
|
Expect(_DataFormat.capitalizeEachWord('Dogs-with-guns 12321'))
|
|
89
89
|
.to.equal('Dogs-With-Guns 12321');
|
|
90
90
|
Expect(_DataFormat.cleanNonAlphaCharacters(_DataFormat.capitalizeEachWord('meadow-endpoints')))
|
|
@@ -99,7 +99,7 @@ suite
|
|
|
99
99
|
(fTestComplete)=>
|
|
100
100
|
{
|
|
101
101
|
let testFable = new libFable({LogStreams: false});
|
|
102
|
-
let _DataFormat = testFable.
|
|
102
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
103
103
|
// Test the enclosure cleaning function
|
|
104
104
|
Expect(_DataFormat
|
|
105
105
|
.cleanEnclosureWrapCharacters('`', '`Dogs`'))
|
|
@@ -133,7 +133,7 @@ suite
|
|
|
133
133
|
(fTestComplete)=>
|
|
134
134
|
{
|
|
135
135
|
let testFable = new libFable({LogStreams: false});
|
|
136
|
-
let _DataFormat = testFable.
|
|
136
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
137
137
|
Expect(_DataFormat
|
|
138
138
|
.stringStartsWith('Dogs', 'Do'))
|
|
139
139
|
.to.equal(true);
|
|
@@ -155,7 +155,7 @@ suite
|
|
|
155
155
|
(fTestComplete)=>
|
|
156
156
|
{
|
|
157
157
|
let testFable = new libFable({LogStreams: false});
|
|
158
|
-
let _DataFormat = testFable.
|
|
158
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
159
159
|
_DataFormat._UseEngineStringStartsWith = false;
|
|
160
160
|
Expect(_DataFormat
|
|
161
161
|
.stringStartsWith('Dogs', 'Do'))
|
|
@@ -178,7 +178,7 @@ suite
|
|
|
178
178
|
(fTestComplete)=>
|
|
179
179
|
{
|
|
180
180
|
let testFable = new libFable({LogStreams: false});
|
|
181
|
-
let _DataFormat = testFable.
|
|
181
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
182
182
|
Expect(_DataFormat
|
|
183
183
|
.stringEndsWith('Dogs', 'gs'))
|
|
184
184
|
.to.equal(true);
|
|
@@ -200,7 +200,7 @@ suite
|
|
|
200
200
|
(fTestComplete)=>
|
|
201
201
|
{
|
|
202
202
|
let testFable = new libFable({LogStreams: false});
|
|
203
|
-
let _DataFormat = testFable.
|
|
203
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
204
204
|
_DataFormat._UseEngineStringEndsWith = false;
|
|
205
205
|
Expect(_DataFormat
|
|
206
206
|
.stringEndsWith('Dogs', 'gs'))
|
|
@@ -230,7 +230,7 @@ suite
|
|
|
230
230
|
(fTestComplete)=>
|
|
231
231
|
{
|
|
232
232
|
let testFable = new libFable({LogStreams: false});
|
|
233
|
-
let _DataFormat = testFable.
|
|
233
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
234
234
|
Expect(_DataFormat
|
|
235
235
|
.cleanNonAlphaCharacters('Dogs'))
|
|
236
236
|
.to.equal('Dogs');
|
|
@@ -254,7 +254,7 @@ suite
|
|
|
254
254
|
(fTestComplete)=>
|
|
255
255
|
{
|
|
256
256
|
let testFable = new libFable({LogStreams: false});
|
|
257
|
-
let _DataFormat = testFable.
|
|
257
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
258
258
|
// The usual use case (e.g. for zero padding dates)
|
|
259
259
|
Expect(_DataFormat.stringPadStart('9', 2, '0'))
|
|
260
260
|
.to.equal('09');
|
|
@@ -282,7 +282,7 @@ suite
|
|
|
282
282
|
(fTestComplete)=>
|
|
283
283
|
{
|
|
284
284
|
let testFable = new libFable({LogStreams: false});
|
|
285
|
-
let _DataFormat = testFable.
|
|
285
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
286
286
|
// The usual use case (e.g. for left justifying text in fixed-width scenarios)
|
|
287
287
|
Expect(_DataFormat.stringPadEnd('Bob', 10, ' '))
|
|
288
288
|
.to.equal('Bob ');
|
|
@@ -29,7 +29,7 @@ suite
|
|
|
29
29
|
(fTestComplete)=>
|
|
30
30
|
{
|
|
31
31
|
let testFable = new libFable({LogStreams: false});
|
|
32
|
-
let _DataFormat = testFable.
|
|
32
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
33
33
|
Expect(_DataFormat
|
|
34
34
|
.formatterAddCommasToNumber(1000))
|
|
35
35
|
.to.equal('1,000');
|
|
@@ -54,7 +54,7 @@ suite
|
|
|
54
54
|
(fTestComplete)=>
|
|
55
55
|
{
|
|
56
56
|
let testFable = new libFable({LogStreams: false});
|
|
57
|
-
let _DataFormat = testFable.
|
|
57
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
58
58
|
Expect(_DataFormat
|
|
59
59
|
.formatterDollars(1000))
|
|
60
60
|
.to.equal('$1,000.00');
|
|
@@ -82,7 +82,7 @@ suite
|
|
|
82
82
|
(fTestComplete)=>
|
|
83
83
|
{
|
|
84
84
|
let testFable = new libFable({LogStreams: false});
|
|
85
|
-
let _DataFormat = testFable.
|
|
85
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
86
86
|
Expect(_DataFormat
|
|
87
87
|
.formatterRoundNumber(1000, 2))
|
|
88
88
|
.to.equal('1000.00');
|
|
@@ -29,7 +29,7 @@ suite
|
|
|
29
29
|
(fTestComplete)=>
|
|
30
30
|
{
|
|
31
31
|
let testFable = new libFable({LogStreams: false});
|
|
32
|
-
let _DataFormat = testFable.
|
|
32
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
33
33
|
Expect(_DataFormat
|
|
34
34
|
.stringBeforeMatch('Dogs are cool', 'are'))
|
|
35
35
|
.to.equal('Dogs ');
|
|
@@ -48,7 +48,7 @@ suite
|
|
|
48
48
|
(fTestComplete)=>
|
|
49
49
|
{
|
|
50
50
|
let testFable = new libFable({LogStreams: false});
|
|
51
|
-
let _DataFormat = testFable.
|
|
51
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
52
52
|
Expect(_DataFormat
|
|
53
53
|
.stringAfterMatch('Dogs are cool', 'are'))
|
|
54
54
|
.to.equal(' cool');
|
|
@@ -67,7 +67,7 @@ suite
|
|
|
67
67
|
(fTestComplete)=>
|
|
68
68
|
{
|
|
69
69
|
let testFable = new libFable({LogStreams: false});
|
|
70
|
-
let _DataFormat = testFable.
|
|
70
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
71
71
|
Expect(_DataFormat
|
|
72
72
|
.stringCountEnclosures('Dogs (are) cool'))
|
|
73
73
|
.to.equal(1);
|
|
@@ -100,7 +100,7 @@ suite
|
|
|
100
100
|
(fTestComplete)=>
|
|
101
101
|
{
|
|
102
102
|
let testFable = new libFable({LogStreams: false});
|
|
103
|
-
let _DataFormat = testFable.
|
|
103
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
104
104
|
Expect(_DataFormat
|
|
105
105
|
.stringGetEnclosureValueByIndex('Dogs (are) cool', 0))
|
|
106
106
|
.to.equal('are');
|
|
@@ -135,7 +135,7 @@ suite
|
|
|
135
135
|
(fTestComplete)=>
|
|
136
136
|
{
|
|
137
137
|
let testFable = new libFable({LogStreams: false});
|
|
138
|
-
let _DataFormat = testFable.
|
|
138
|
+
let _DataFormat = testFable.services.DataFormat;
|
|
139
139
|
Expect(_DataFormat
|
|
140
140
|
.stringRemoveEnclosureByIndex('Dogs (are) cool', 0))
|
|
141
141
|
.to.equal('Dogs cool');
|
|
@@ -29,9 +29,9 @@ suite
|
|
|
29
29
|
let testFable = new libFable();
|
|
30
30
|
let tmpOperation = testFable.serviceManager.instantiateServiceProvider('Operation', {Name: 'Big Complex Integration Operation'}, 'INTEGRATION-123');
|
|
31
31
|
Expect(tmpOperation).to.be.an('object');
|
|
32
|
-
Expect(testFable.
|
|
33
|
-
Expect(testFable.
|
|
34
|
-
Expect(testFable.
|
|
32
|
+
Expect(testFable.serviceMap.Operation['INTEGRATION-123']).to.equal(tmpOperation);
|
|
33
|
+
Expect(testFable.serviceMap.Operation['BADHASH']).to.be.undefined;
|
|
34
|
+
Expect(testFable.serviceMap.Operation.hasOwnProperty('INTEGRATION-123')).to.equal(true);
|
|
35
35
|
tmpOperation.log.info(`Operation GUID ${tmpOperation.GUID} ---- Test 123`);
|
|
36
36
|
Expect(tmpOperation.state.Log.length).to.equal(1);
|
|
37
37
|
Expect(tmpOperation.state.Log[0]).to.contain('Test 123');
|
|
@@ -51,7 +51,7 @@ suite
|
|
|
51
51
|
Expect(tmpCollisionOperation).to.be.an('object');
|
|
52
52
|
Expect(tmpCollisionOperation.name).to.equal('Another Big Complex Integration Operation with Colliding Name');
|
|
53
53
|
|
|
54
|
-
Expect(testFable.
|
|
54
|
+
Expect(testFable.serviceMap.Operation['INTEGRATION-123']).to.equal(tmpCollisionOperation);
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
);
|
|
@@ -63,7 +63,7 @@ suite
|
|
|
63
63
|
let testFable = new libFable();
|
|
64
64
|
let tmpOperation = testFable.serviceManager.instantiateServiceProvider('Operation', {Name:'Another Big Complex Integration Operation'});
|
|
65
65
|
Expect(tmpOperation).to.be.an('object');
|
|
66
|
-
Expect(testFable.
|
|
66
|
+
Expect(testFable.serviceMap.Operation.hasOwnProperty(tmpOperation.Hash)).to.equal(true);
|
|
67
67
|
Expect(tmpOperation.state.Log.length).to.equal(0);
|
|
68
68
|
let tmpText = `Operation ${tmpOperation.Hash} starting up...`;
|
|
69
69
|
tmpOperation.log.info(tmpText);
|
|
@@ -107,9 +107,9 @@ suite
|
|
|
107
107
|
}
|
|
108
108
|
testFable.serviceManager.instantiateServiceProvider('SimpleService', { SomeOption: true }, 'TheBestOne');
|
|
109
109
|
|
|
110
|
-
Expect(testFable.serviceManager.
|
|
111
|
-
Expect(testFable.serviceManager.
|
|
112
|
-
Expect(testFable.serviceManager.
|
|
110
|
+
Expect(testFable.serviceManager.services.SimpleService).to.be.an('object');
|
|
111
|
+
Expect(testFable.serviceManager.services.SimpleService.MyFancyProperty).to.equal('Fancy');
|
|
112
|
+
Expect(testFable.serviceManager.serviceMap.SimpleService.TheBestOne.MyFancyProperty).to.equal('Fancy');
|
|
113
113
|
}
|
|
114
114
|
);
|
|
115
115
|
test
|
|
@@ -123,11 +123,11 @@ suite
|
|
|
123
123
|
|
|
124
124
|
Expect(testFable.serviceManager.services['SimpleService']['SimpleService-123']).to.be.an('object');
|
|
125
125
|
|
|
126
|
-
Expect(testFable.serviceManager.
|
|
126
|
+
Expect(testFable.serviceManager.services['SimpleService']).to.be.an('object');
|
|
127
127
|
|
|
128
|
-
testFable.serviceManager.
|
|
128
|
+
testFable.serviceManager.services.SimpleService.doSomething();
|
|
129
129
|
|
|
130
|
-
Expect(testFable.serviceManager.
|
|
130
|
+
Expect(testFable.serviceManager.services['SimpleService'].Hash).to.equal('SimpleService-123');
|
|
131
131
|
}
|
|
132
132
|
);
|
|
133
133
|
test
|
|
@@ -159,8 +159,8 @@ suite
|
|
|
159
159
|
let tmpService = testFable.serviceManager.instantiateServiceProviderWithoutRegistration('SimpleService', { SomeOption: true }, 'SimpleService-99');
|
|
160
160
|
let tmpServiceFromPrototype = testFable.serviceManager.instantiateServiceProviderFromPrototype('SimpleService', { SomeOption: true }, 'SimpleService-100', SimpleService);
|
|
161
161
|
|
|
162
|
-
Expect(testFable.
|
|
163
|
-
Expect(testFable.
|
|
162
|
+
Expect(testFable.serviceMap.SimpleService['SimpleService-99']).to.be.an('undefined');
|
|
163
|
+
Expect(testFable.serviceMap.SimpleService['SimpleService-100']).to.be.an('object');
|
|
164
164
|
Expect(tmpServiceFromPrototype).to.be.an('object');
|
|
165
165
|
|
|
166
166
|
Expect(tmpService).to.be.an('object');
|
|
@@ -178,25 +178,25 @@ suite
|
|
|
178
178
|
testFable.serviceManager.addServiceType('DatabaseService', MockDatabaseService);
|
|
179
179
|
|
|
180
180
|
testFable.serviceManager.instantiateServiceProvider('SimpleService', { SomeOption: true });
|
|
181
|
-
testFable.serviceManager.
|
|
181
|
+
testFable.serviceManager.services.SimpleService.doSomething();
|
|
182
182
|
|
|
183
183
|
testFable.serviceManager.instantiateServiceProvider('DatabaseService', { ConnectionString: 'mongodb://localhost:27017/test' }, 'PrimaryConnection');
|
|
184
184
|
|
|
185
|
-
Expect(testFable.serviceManager.
|
|
185
|
+
Expect(testFable.serviceManager.services.DatabaseService.Hash).to.equal('PrimaryConnection');
|
|
186
186
|
|
|
187
187
|
testFable.serviceManager.instantiateServiceProvider('DatabaseService', { ConnectionString: 'mongodb://localhost:27017/test' }, 'SecondaryConnection');
|
|
188
188
|
|
|
189
|
-
Expect(testFable.serviceManager.
|
|
189
|
+
Expect(testFable.serviceManager.services.DatabaseService.Hash).to.equal('PrimaryConnection');
|
|
190
190
|
|
|
191
|
-
testFable.serviceManager.
|
|
192
|
-
testFable.serviceManager.
|
|
191
|
+
testFable.serviceManager.services.DatabaseService.connect();
|
|
192
|
+
testFable.serviceManager.services.DatabaseService.commit('Test Record');
|
|
193
193
|
|
|
194
194
|
testFable.serviceManager.setDefaultServiceInstantiation('DatabaseService', 'SecondaryConnection');
|
|
195
195
|
|
|
196
|
-
testFable.serviceManager.
|
|
197
|
-
testFable.serviceManager.
|
|
196
|
+
testFable.serviceManager.services.DatabaseService.connect();
|
|
197
|
+
testFable.serviceManager.services.DatabaseService.commit('Another Test Record');
|
|
198
198
|
|
|
199
|
-
Expect(testFable.serviceManager.
|
|
199
|
+
Expect(testFable.serviceManager.services.DatabaseService.Hash).to.equal('SecondaryConnection');
|
|
200
200
|
}
|
|
201
201
|
);
|
|
202
202
|
|
|
@@ -241,10 +241,10 @@ suite
|
|
|
241
241
|
|
|
242
242
|
testFable.serviceManager.connectPreinitServiceProviderInstance(tmpCoreService);
|
|
243
243
|
|
|
244
|
-
Expect(testFable.
|
|
245
|
-
Expect(testFable.
|
|
244
|
+
Expect(testFable.serviceMap.MockCoreService['MockCoreService-2']).to.be.an('object');
|
|
245
|
+
Expect(testFable.services.MockCoreService).to.be.an('object');
|
|
246
246
|
|
|
247
|
-
Expect(testFable.
|
|
247
|
+
Expect(testFable.services.MockCoreService.fable.log).to.be.an('object');
|
|
248
248
|
}
|
|
249
249
|
)
|
|
250
250
|
|
|
@@ -259,25 +259,25 @@ suite
|
|
|
259
259
|
testFable.serviceManager.addServiceType('DatabaseService', MockDatabaseService);
|
|
260
260
|
|
|
261
261
|
testFable.serviceManager.instantiateServiceProvider('SimpleService', { SomeOption: true });
|
|
262
|
-
testFable.serviceManager.
|
|
262
|
+
testFable.serviceManager.services.SimpleService.doSomething();
|
|
263
263
|
|
|
264
264
|
testFable.serviceManager.instantiateServiceProvider('DatabaseService', { ConnectionString: 'mongodb://localhost:27017/test' }, 'PrimaryConnection');
|
|
265
265
|
|
|
266
|
-
Expect(testFable.serviceManager.
|
|
266
|
+
Expect(testFable.serviceManager.services.DatabaseService.Hash).to.equal('PrimaryConnection');
|
|
267
267
|
|
|
268
268
|
testFable.serviceManager.instantiateServiceProvider('DatabaseService', { ConnectionString: 'mongodb://localhost:27017/test' }, 'SecondaryConnection');
|
|
269
269
|
|
|
270
|
-
Expect(testFable.serviceManager.
|
|
270
|
+
Expect(testFable.serviceManager.services.DatabaseService.Hash).to.equal('PrimaryConnection');
|
|
271
271
|
|
|
272
|
-
testFable.serviceManager.
|
|
273
|
-
testFable.serviceManager.
|
|
272
|
+
testFable.serviceManager.services.DatabaseService.connect();
|
|
273
|
+
testFable.serviceManager.services.DatabaseService.commit('Test Record');
|
|
274
274
|
|
|
275
275
|
Expect(testFable.serviceManager.setDefaultServiceInstantiation('DatabaseService', 'TertiaryConnection')).to.be.false;
|
|
276
276
|
|
|
277
|
-
testFable.serviceManager.
|
|
278
|
-
testFable.serviceManager.
|
|
277
|
+
testFable.serviceManager.services.DatabaseService.connect();
|
|
278
|
+
testFable.serviceManager.services.DatabaseService.commit('Another Test Record');
|
|
279
279
|
|
|
280
|
-
Expect(testFable.serviceManager.
|
|
280
|
+
Expect(testFable.serviceManager.services.DatabaseService.Hash).to.equal('PrimaryConnection');
|
|
281
281
|
}
|
|
282
282
|
);
|
|
283
283
|
}
|
package/test/Fable_tests.js
CHANGED
|
@@ -106,7 +106,7 @@ suite
|
|
|
106
106
|
.to.equal('ApplicationNameHere');
|
|
107
107
|
Expect(testFable.settings.ProductVersion)
|
|
108
108
|
.to.equal('0.0.0');
|
|
109
|
-
testFable.
|
|
109
|
+
testFable.services.SettingsManager.merge({Product:'TestProduct'});
|
|
110
110
|
Expect(testFable.settings.Product)
|
|
111
111
|
.to.equal('TestProduct');
|
|
112
112
|
Expect(testFable.settings.ProductVersion)
|
package/test/Utility_tests.js
CHANGED
|
@@ -36,7 +36,7 @@ suite
|
|
|
36
36
|
function()
|
|
37
37
|
{
|
|
38
38
|
testFable = new libFable();
|
|
39
|
-
let tmpTemplate = testFable.
|
|
39
|
+
let tmpTemplate = testFable.services.Utility.template('Something');
|
|
40
40
|
Expect(tmpTemplate).to.be.a('function');
|
|
41
41
|
}
|
|
42
42
|
);
|
|
@@ -46,7 +46,7 @@ suite
|
|
|
46
46
|
function()
|
|
47
47
|
{
|
|
48
48
|
testFable = new libFable();
|
|
49
|
-
let tmpTemplate = testFable.
|
|
49
|
+
let tmpTemplate = testFable.services.Utility.template('Something');
|
|
50
50
|
Expect(tmpTemplate).to.be.a('function');
|
|
51
51
|
Expect(tmpTemplate()).to.equal('Something');
|
|
52
52
|
}
|
|
@@ -57,7 +57,7 @@ suite
|
|
|
57
57
|
function()
|
|
58
58
|
{
|
|
59
59
|
testFable = new libFable();
|
|
60
|
-
let tmpTemplate = testFable.
|
|
60
|
+
let tmpTemplate = testFable.services.Utility.template('There // %> are \\ */ /* <%= Count %> things....');
|
|
61
61
|
Expect(tmpTemplate).to.be.a('function');
|
|
62
62
|
Expect(tmpTemplate({Count:1000})).to.equal('There // %> are \\ */ /* 1000 things....');
|
|
63
63
|
}
|
|
@@ -68,10 +68,10 @@ suite
|
|
|
68
68
|
function()
|
|
69
69
|
{
|
|
70
70
|
testFable = new libFable();
|
|
71
|
-
let tmpTemplate = testFable.
|
|
71
|
+
let tmpTemplate = testFable.services.Utility.template('There are so many of these things (<%= Count %> to be exact)....');
|
|
72
72
|
Expect(tmpTemplate).to.be.a('function');
|
|
73
73
|
Expect(tmpTemplate({Count:1000})).to.equal('There are so many of these things (1000 to be exact)....');
|
|
74
|
-
let tmpOtherTemplate = testFable.
|
|
74
|
+
let tmpOtherTemplate = testFable.services.Utility.template('Things count: <%= Count %>');
|
|
75
75
|
Expect(tmpOtherTemplate).to.be.a('function');
|
|
76
76
|
Expect(tmpOtherTemplate({Count:600})).to.equal('Things count: 600');
|
|
77
77
|
Expect(tmpTemplate({Count:256})).to.equal('There are so many of these things (256 to be exact)....');
|
|
@@ -83,16 +83,16 @@ suite
|
|
|
83
83
|
function()
|
|
84
84
|
{
|
|
85
85
|
testFable = new libFable();
|
|
86
|
-
testFable.
|
|
87
|
-
testFable.
|
|
86
|
+
testFable.services.Utility.buildHashedTemplate('HeadLine', '<h1><%= TitleText %> Page</h1>');
|
|
87
|
+
testFable.services.Utility.buildHashedTemplate('Slogan', '<p>Some people, like <%= Name %>, have all the fun.</p>');
|
|
88
88
|
|
|
89
89
|
// Access the low level service render function
|
|
90
|
-
Expect(testFable.
|
|
91
|
-
Expect(testFable.
|
|
90
|
+
Expect(testFable.serviceMap.Template.HeadLine.renderFunction({TitleText:'Test'})).to.equal('<h1>Test Page</h1>');
|
|
91
|
+
Expect(testFable.serviceMap.Template.Slogan.renderFunction({Name:'Jim'})).to.equal('<p>Some people, like Jim, have all the fun.</p>');
|
|
92
92
|
|
|
93
93
|
// Use the high level simpler one
|
|
94
|
-
Expect(testFable.
|
|
95
|
-
Expect(testFable.
|
|
94
|
+
Expect(testFable.services.Utility.templates.HeadLine({TitleText:'A New'})).to.equal('<h1>A New Page</h1>');
|
|
95
|
+
Expect(testFable.services.Utility.templates.Slogan({Name:'Bob'})).to.equal('<p>Some people, like Bob, have all the fun.</p>');
|
|
96
96
|
}
|
|
97
97
|
);
|
|
98
98
|
test
|
|
@@ -101,7 +101,7 @@ suite
|
|
|
101
101
|
function()
|
|
102
102
|
{
|
|
103
103
|
testFable = new libFable();
|
|
104
|
-
let tmpTemplate = testFable.
|
|
104
|
+
let tmpTemplate = testFable.services.Utility.template('There are <%= Count %> things....', {Count:1000});
|
|
105
105
|
Expect(tmpTemplate).to.equal('There are 1000 things....');
|
|
106
106
|
}
|
|
107
107
|
);
|
|
@@ -111,7 +111,7 @@ suite
|
|
|
111
111
|
function()
|
|
112
112
|
{
|
|
113
113
|
testFable = new libFable();
|
|
114
|
-
let tmpResult = testFable.
|
|
114
|
+
let tmpResult = testFable.services.Utility.extend({SomeValue:'here'});
|
|
115
115
|
Expect(tmpResult).to.have.a.property('SomeValue')
|
|
116
116
|
.that.is.a('string');
|
|
117
117
|
Expect(tmpResult.SomeValue).to.equal('here')
|
|
@@ -123,7 +123,7 @@ suite
|
|
|
123
123
|
function()
|
|
124
124
|
{
|
|
125
125
|
testFable = new libFable();
|
|
126
|
-
let tmpResult = testFable.
|
|
126
|
+
let tmpResult = testFable.services.Utility.extend({SomeValue:'here',Size:10},{Color:'Red',Size:20});
|
|
127
127
|
Expect(tmpResult).to.have.a.property('SomeValue')
|
|
128
128
|
.that.is.a('string');
|
|
129
129
|
Expect(tmpResult.SomeValue).to.equal('here');
|
|
@@ -137,7 +137,7 @@ suite
|
|
|
137
137
|
function()
|
|
138
138
|
{
|
|
139
139
|
testFable = new libFable();
|
|
140
|
-
let tmpResult = testFable.
|
|
140
|
+
let tmpResult = testFable.services.Utility.extend(
|
|
141
141
|
{SomeValue:'here',Size:10, Race:'Human'},
|
|
142
142
|
{Color:'Red',Size:20, Band:'Metalocalypse'},
|
|
143
143
|
{Name:'Bilbo', Size:15, Race:'Hobbit', Band:'The dead hobbitz'});
|
|
@@ -165,20 +165,20 @@ suite
|
|
|
165
165
|
*/
|
|
166
166
|
// Regular Expressions for easy conversion of underscore tests:
|
|
167
167
|
// S: assert.deepEqual\(_.chunk\((.*)\), (.*), '
|
|
168
|
-
// R: Expect(testFable.
|
|
169
|
-
Expect(testFable.
|
|
168
|
+
// R: Expect(testFable.services.Utility.chunk($1)).to.deep.equal($2); // $3
|
|
169
|
+
Expect(testFable.services.Utility.chunk([], 2)).to.deep.equal([]); // chunk for empty array returns an empty array');
|
|
170
170
|
|
|
171
|
-
Expect(testFable.
|
|
172
|
-
Expect(testFable.
|
|
173
|
-
Expect(testFable.
|
|
171
|
+
Expect(testFable.services.Utility.chunk([1, 2, 3], 0)).to.deep.equal([]); // chunk into parts of 0 elements returns empty array');
|
|
172
|
+
Expect(testFable.services.Utility.chunk([1, 2, 3], -1)).to.deep.equal([]); // chunk into parts of negative amount of elements returns an empty array');
|
|
173
|
+
Expect(testFable.services.Utility.chunk([1, 2, 3])).to.deep.equal([]); // defaults to empty array (chunk size 0)');
|
|
174
174
|
|
|
175
|
-
Expect(testFable.
|
|
175
|
+
Expect(testFable.services.Utility.chunk([1, 2, 3], 1)).to.deep.equal([[1], [2], [3]]); // chunk into parts of 1 elements returns original array');
|
|
176
176
|
|
|
177
|
-
Expect(testFable.
|
|
178
|
-
Expect(testFable.
|
|
177
|
+
Expect(testFable.services.Utility.chunk([1, 2, 3], 3)).to.deep.equal([[1, 2, 3]]); // chunk into parts of current array length elements returns the original array');
|
|
178
|
+
Expect(testFable.services.Utility.chunk([1, 2, 3], 5)).to.deep.equal([[1, 2, 3]]); // chunk into parts of more then current array length elements returns the original array');
|
|
179
179
|
|
|
180
|
-
Expect(testFable.
|
|
181
|
-
Expect(testFable.
|
|
180
|
+
Expect(testFable.services.Utility.chunk([10, 20, 30, 40, 50, 60, 70], 2)).to.deep.equal([[10, 20], [30, 40], [50, 60], [70]]); // chunk into parts of less then current array length elements');
|
|
181
|
+
Expect(testFable.services.Utility.chunk([10, 20, 30, 40, 50, 60, 70], 3)).to.deep.equal([[10, 20, 30], [40, 50, 60], [70]]); // chunk into parts of less then current array length elements');
|
|
182
182
|
}
|
|
183
183
|
);
|
|
184
184
|
test
|
|
@@ -187,12 +187,12 @@ suite
|
|
|
187
187
|
function(fDone)
|
|
188
188
|
{
|
|
189
189
|
testFable = new libFable();
|
|
190
|
-
Expect(testFable.
|
|
191
|
-
Expect(testFable.
|
|
192
|
-
Expect(testFable.
|
|
193
|
-
Expect(testFable.
|
|
194
|
-
Expect(testFable.
|
|
195
|
-
Expect(testFable.
|
|
190
|
+
Expect(testFable.services.Utility.isoStringToDate('1986-06-11T09:34:46.012Z').getTime()).to.equal(518866486012);
|
|
191
|
+
Expect(testFable.services.Utility.isoStringToDate('2022-11-04T11:34:46.000Z').getTime()).to.equal(1667561686000);
|
|
192
|
+
Expect(testFable.services.Utility.isoStringToDate('2022-11-04T11:34:45.000Z').getTime()).to.equal(1667561685000);
|
|
193
|
+
Expect(testFable.services.Utility.isoStringToDate('1986-06-11T09:34:46.012Z').getTime()).to.equal(518866486012);
|
|
194
|
+
Expect(testFable.services.Utility.isoStringToDate('1986-06-11T09:34:46.012Z+0200').getTime()).to.equal(519586486012);
|
|
195
|
+
Expect(testFable.services.Utility.isoStringToDate('1986-06-11T09:34:46.012Z+0200').getTime()).to.equal(519586486012);
|
|
196
196
|
fDone();
|
|
197
197
|
}
|
|
198
198
|
)
|
|
@@ -205,7 +205,7 @@ suite
|
|
|
205
205
|
|
|
206
206
|
let tmpState = {};
|
|
207
207
|
|
|
208
|
-
testFable.
|
|
208
|
+
testFable.services.Utility.waterfall([
|
|
209
209
|
(fStageComplete)=>
|
|
210
210
|
{
|
|
211
211
|
tmpState.Name = 'The Pixies';
|
|
@@ -235,7 +235,7 @@ suite
|
|
|
235
235
|
|
|
236
236
|
let tmpData = ['a','b','c','d','e'];
|
|
237
237
|
|
|
238
|
-
testFable.
|
|
238
|
+
testFable.services.Utility.eachLimit(tmpData, 2,
|
|
239
239
|
(pItem, fCallback)=>
|
|
240
240
|
{
|
|
241
241
|
tmpState[pItem] = pItem;
|