@schukai/monster 4.92.0 → 4.94.0

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.
@@ -288,7 +288,11 @@ describe('Formatter', function () {
288
288
  mykey: '${mykey}',
289
289
  };
290
290
 
291
- const formatter = new Formatter(inputObj);
291
+ const formatter = new Formatter(inputObj, {
292
+ recursion: {
293
+ detectCycles: false,
294
+ },
295
+ });
292
296
 
293
297
  const text = '${mykey}';
294
298
  let formattedText = text;
@@ -300,8 +304,28 @@ describe('Formatter', function () {
300
304
 
301
305
  expect(() => formatter.format(formattedText)).to.throw('too deep nesting');
302
306
  });
307
+
308
+ it('should detect recursion cycles by default', () => {
309
+ const formatter = new Formatter({
310
+ a: '${b}',
311
+ b: '${a}',
312
+ });
313
+
314
+ expect(() => formatter.format('${a}')).to.throw('cycle detected in formatter');
315
+ });
316
+
317
+ it('should allow configuring max depth', () => {
318
+ const formatter = new Formatter({value: '${value}'}, {
319
+ recursion: {
320
+ maxDepth: 3,
321
+ detectCycles: false,
322
+ },
323
+ });
324
+
325
+ expect(() => formatter.format('${value}')).to.throw('too deep nesting');
326
+ });
303
327
 
304
328
  });
305
329
 
306
330
 
307
- });
331
+ });