@mablhq/mabl-cli 2.51.4 → 2.51.10

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.
@@ -99,17 +99,6 @@ function getAssertionTypesForTarget(target) {
99
99
  ].includes(assertType.value));
100
100
  case newman_types_1.AssertionTarget.Header:
101
101
  case newman_types_1.AssertionTarget.JSONBody:
102
- return exports.ASSERT_TYPES.filter((assertType) => [
103
- newman_types_1.AssertionType.Contains,
104
- newman_types_1.AssertionType.DoesNotContain,
105
- newman_types_1.AssertionType.EndsWith,
106
- newman_types_1.AssertionType.Equals,
107
- newman_types_1.AssertionType.MatchesRegExp,
108
- newman_types_1.AssertionType.NotEquals,
109
- newman_types_1.AssertionType.NotPresent,
110
- newman_types_1.AssertionType.Present,
111
- newman_types_1.AssertionType.StartsWith,
112
- ].includes(assertType.value));
113
102
  default:
114
103
  return exports.ASSERT_TYPES;
115
104
  }
@@ -447,6 +436,27 @@ function generateJsonBodyAssertion(description, assertType, requiresValues, path
447
436
  if (requiresValues) {
448
437
  propertyAccessor = valueToUnquotedString(propertyAccessor);
449
438
  }
439
+ switch (assertType) {
440
+ case 'Present':
441
+ case 'NotPresent':
442
+ case 'Equals':
443
+ case 'NotEquals':
444
+ case 'Contains':
445
+ case 'DoesNotContain':
446
+ case 'StartsWith':
447
+ case 'EndsWith':
448
+ case 'MatchesRegExp':
449
+ break;
450
+ case 'GreaterThan':
451
+ case 'GreaterThanOrEqualTo':
452
+ case 'LessThan':
453
+ case 'LessThanOrEqualTo':
454
+ propertyAccessor = `parseFloat(${propertyAccessor})`;
455
+ expectedValue = `parseFloat(${expectedValue})`;
456
+ break;
457
+ default:
458
+ throw new Error(`Unexpected header assert type: ${assertType}`);
459
+ }
450
460
  return generatePostmanAssertion(description, propertyAccessor, assertType, expectedValue, caseSensitive);
451
461
  }
452
462
  function generateJsonBodyVariableAssignment(variableName, path) {
@@ -504,6 +514,7 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
504
514
  }
505
515
  const normalizedHeaderName = JSON.stringify(headerName);
506
516
  let test;
517
+ let target = `pm.response.headers.get(${normalizedHeaderName})`;
507
518
  switch (assertType) {
508
519
  case 'Present':
509
520
  test = `pm.response.to.have.header(${normalizedHeaderName})`;
@@ -523,11 +534,13 @@ function generateHeaderAssertion(description, assertType, headerName, expectedVa
523
534
  case 'GreaterThanOrEqualTo':
524
535
  case 'LessThan':
525
536
  case 'LessThanOrEqualTo':
526
- return;
537
+ target = `parseFloat(${target})`;
538
+ expectedValue = `parseFloat(${expectedValue})`;
539
+ break;
527
540
  default:
528
541
  throw new Error(`Unexpected header assert type: ${assertType}`);
529
542
  }
530
- return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(`pm.response.headers.get(${normalizedHeaderName})`, assertType, expectedValue, caseSensitive));
543
+ return generatePostmanTest(description, test !== null && test !== void 0 ? test : generatePostmanExpect(target, assertType, expectedValue, caseSensitive));
531
544
  }
532
545
  function generateSizeAssertion(description, target, type, expectedValue) {
533
546
  if (!(expectedValue === null || expectedValue === void 0 ? void 0 : expectedValue.length)) {