manyfest 1.0.30 → 1.0.32

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.
@@ -194,6 +194,132 @@ suite
194
194
  fTestComplete();
195
195
  }
196
196
  );
197
+ test
198
+ (
199
+ 'Access Functions',
200
+ (fTestComplete)=>
201
+ {
202
+ let _Manyfest = new libManyfest();
203
+ let tmpComplexObject = (
204
+ {
205
+ "Name": "Yadda",
206
+ "TheFunction": (pValue) => { return `Value is: ${pValue}`; }
207
+ });
208
+
209
+ Expect(_Manyfest.getValueAtAddress(tmpComplexObject, 'Name'))
210
+ .to.equal('Yadda');
211
+
212
+ Expect(_Manyfest.getValueAtAddress(tmpComplexObject, 'TheFunction()'))
213
+ .to.equal('Value is: undefined');
214
+
215
+ Expect(_Manyfest.getValueAtAddress(tmpComplexObject, 'TheFunction(Name)'))
216
+ .to.equal('Value is: Yadda');
217
+
218
+ fTestComplete();
219
+ }
220
+ );
221
+ test
222
+ (
223
+ 'Complex Functions that Mutate State and deal with Parameters',
224
+ (fTestComplete)=>
225
+ {
226
+ // Create a compmlex mock object to check metadata on.
227
+ let _MockObject = (
228
+ {
229
+ "Name": "Yadda",
230
+ "TheFunction": (pValue) => { return `Value is: ${pValue}`; },
231
+ "ComplexFunction": (pValue, pOutput) => { return `Value is: ${pValue} and would output as ${pOutput}`; },
232
+ "Behaviors":
233
+ {
234
+ "Value": 0,
235
+ "Increment": function ()
236
+ {
237
+ this.Value++; return this.Value;
238
+ },
239
+ "SillyObject": function()
240
+ {
241
+ return { Cost: 1.00, Name: 'Beanie Baby', Stores: ['Aberdeen', 'Seattle', 'Tacoma'] }
242
+ },
243
+ "FormatOutput": function () { return `My magic value is: ${this.Value}`; }
244
+ },
245
+ "Manyfest":
246
+ {
247
+ Scope:'Function.Mock',
248
+ Descriptors:
249
+ {
250
+ "metadata.creator":
251
+ {
252
+ Name:'Creator',
253
+ Hash:'Creator'
254
+ }
255
+ }
256
+ },
257
+ "Data": _SampleDataArchiveOrgFrankenberry
258
+ });
259
+ let _Manyfest = new libManyfest(_MockObject.Manyfest);
260
+
261
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'Name')).to.equal('Yadda');
262
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'TheFunction()')).to.equal('Value is: undefined');
263
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'TheFunction(Name)')).to.equal('Value is: Yadda');
264
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'ComplexFunction(Name,Name)')).to.equal('Value is: Yadda and would output as Yadda');
265
+
266
+ // This is stupid but works
267
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'ComplexFunction(Name,TheFunction(Manyfest.Descriptors["metadata.creator"].Hash))'))
268
+ .to.equal('Value is: Yadda and would output as Value is: Creator');
269
+
270
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'Behaviors.Increment()'))
271
+ .to.equal(1);
272
+
273
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'Behaviors.SillyObject().Stores[0]')).to.equal('Aberdeen');
274
+
275
+ fTestComplete();
276
+ }
277
+ );
278
+ test
279
+ (
280
+ 'Functions with fixed and static parameters',
281
+ (fTestComplete)=>
282
+ {
283
+ // Create a compmlex mock object to check metadata on.
284
+ let _MockObject = (
285
+ {
286
+ "Name": "Yadda",
287
+ "ComplexFunction": (pValue, pOutput) => { return `Value is: ${pValue} and would output as ${pOutput}`; },
288
+ "Behaviors":
289
+ {
290
+ "Value": 0,
291
+ "TheFunction": (pValue) => { return `Value is: ${pValue}`; },
292
+ "Increment": function ()
293
+ {
294
+ this.Value++; return this.Value;
295
+ },
296
+ "SillyObject": function()
297
+ {
298
+ return { Cost: 1.00, Name: 'Beanie Baby', Stores: ['Aberdeen', 'Seattle', 'Tacoma'] }
299
+ },
300
+ "FormatOutput": function () { return `My magic value is: ${this.Value}`; }
301
+ },
302
+ "Manyfest":
303
+ {
304
+ Scope:'Function.Mock',
305
+ Descriptors:
306
+ {
307
+ "metadata.creator":
308
+ {
309
+ Name:'Creator',
310
+ Hash:'Creator'
311
+ }
312
+ }
313
+ },
314
+ "Data": _SampleDataArchiveOrgFrankenberry
315
+ });
316
+ let _Manyfest = new libManyfest(_MockObject.Manyfest);
317
+
318
+ Expect(_Manyfest.getValueAtAddress(_MockObject, 'Behaviors.TheFunction("100")')).to.equal('Value is: 100');
319
+
320
+ fTestComplete();
321
+ }
322
+ );
197
323
  }
198
324
  );
199
325
  }