webpipe-js 2.0.42 → 2.0.44

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/dist/index.cjs CHANGED
@@ -1652,6 +1652,11 @@ function printMock(mock, indent = " ") {
1652
1652
  }
1653
1653
  function printCondition(condition, indent = " ") {
1654
1654
  const condType = condition.conditionType.toLowerCase();
1655
+ if (condition.isCallAssertion && condition.callTarget) {
1656
+ const [callType, callName] = condition.callTarget.split(".");
1657
+ const value2 = condition.value.startsWith("`") ? condition.value : condition.value.includes("\n") || condition.value.includes("{") || condition.value.includes("[") ? `\`${condition.value}\`` : condition.value;
1658
+ return `${indent}${condType} call ${callType} ${callName} ${condition.comparison} ${value2}`;
1659
+ }
1655
1660
  if (condition.field === "selector" && condition.selector && condition.domAssert) {
1656
1661
  const selector = condition.selector;
1657
1662
  const formatValue = (val) => {
@@ -1661,13 +1666,13 @@ function printCondition(condition, indent = " ") {
1661
1666
  };
1662
1667
  if (condition.domAssert.kind === "Exists") {
1663
1668
  const operation = condition.comparison === "exists" ? "exists" : "does not exist";
1664
- return `${indent}${condType} selector "${selector}" ${operation}`;
1669
+ return `${indent}${condType} selector \`${selector}\` ${operation}`;
1665
1670
  } else if (condition.domAssert.kind === "Text") {
1666
- return `${indent}${condType} selector "${selector}" text ${condition.comparison} ${formatValue(condition.value)}`;
1671
+ return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${formatValue(condition.value)}`;
1667
1672
  } else if (condition.domAssert.kind === "Count") {
1668
- return `${indent}${condType} selector "${selector}" count ${condition.comparison} ${condition.value}`;
1673
+ return `${indent}${condType} selector \`${selector}\` count ${condition.comparison} ${condition.value}`;
1669
1674
  } else if (condition.domAssert.kind === "Attribute") {
1670
- return `${indent}${condType} selector "${selector}" attribute "${condition.domAssert.name}" ${condition.comparison} ${formatValue(condition.value)}`;
1675
+ return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${formatValue(condition.value)}`;
1671
1676
  }
1672
1677
  }
1673
1678
  const fieldPart = condition.headerName ? `${condition.field} "${condition.headerName}"` : condition.jqExpr ? `${condition.field} \`${condition.jqExpr}\`` : condition.field;
@@ -1680,24 +1685,33 @@ function printTest(test) {
1680
1685
  test.mocks.forEach((mock) => {
1681
1686
  lines.push(printMock(mock, " "));
1682
1687
  });
1683
- lines.push(` when ${formatWhen(test.when)}`);
1684
- if (test.variables) {
1688
+ if (test.variables && test.variables.length > 0) {
1685
1689
  test.variables.forEach((variable) => {
1686
1690
  const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
1687
1691
  lines.push(` let ${variable.name} = ${formattedValue}`);
1688
1692
  });
1693
+ lines.push("");
1689
1694
  }
1690
- if (test.input) {
1691
- lines.push(` with input \`${test.input}\``);
1695
+ lines.push(` when ${formatWhen(test.when)}`);
1696
+ let hasWithClause = false;
1697
+ if (test.headers) {
1698
+ lines.push(` with headers \`${test.headers}\``);
1699
+ hasWithClause = true;
1692
1700
  }
1693
1701
  if (test.body) {
1694
- lines.push(` with body \`${test.body}\``);
1702
+ const prefix = hasWithClause ? "and with" : "with";
1703
+ lines.push(` ${prefix} body \`${test.body}\``);
1704
+ hasWithClause = true;
1695
1705
  }
1696
- if (test.headers) {
1697
- lines.push(` with headers \`${test.headers}\``);
1706
+ if (test.input) {
1707
+ const prefix = hasWithClause ? "and with" : "with";
1708
+ lines.push(` ${prefix} input \`${test.input}\``);
1709
+ hasWithClause = true;
1698
1710
  }
1699
1711
  if (test.cookies) {
1700
- lines.push(` with cookies \`${test.cookies}\``);
1712
+ const prefix = hasWithClause ? "and with" : "with";
1713
+ lines.push(` ${prefix} cookies \`${test.cookies}\``);
1714
+ hasWithClause = true;
1701
1715
  }
1702
1716
  test.conditions.forEach((condition) => {
1703
1717
  lines.push(printCondition(condition));
package/dist/index.mjs CHANGED
@@ -1599,6 +1599,11 @@ function printMock(mock, indent = " ") {
1599
1599
  }
1600
1600
  function printCondition(condition, indent = " ") {
1601
1601
  const condType = condition.conditionType.toLowerCase();
1602
+ if (condition.isCallAssertion && condition.callTarget) {
1603
+ const [callType, callName] = condition.callTarget.split(".");
1604
+ const value2 = condition.value.startsWith("`") ? condition.value : condition.value.includes("\n") || condition.value.includes("{") || condition.value.includes("[") ? `\`${condition.value}\`` : condition.value;
1605
+ return `${indent}${condType} call ${callType} ${callName} ${condition.comparison} ${value2}`;
1606
+ }
1602
1607
  if (condition.field === "selector" && condition.selector && condition.domAssert) {
1603
1608
  const selector = condition.selector;
1604
1609
  const formatValue = (val) => {
@@ -1608,13 +1613,13 @@ function printCondition(condition, indent = " ") {
1608
1613
  };
1609
1614
  if (condition.domAssert.kind === "Exists") {
1610
1615
  const operation = condition.comparison === "exists" ? "exists" : "does not exist";
1611
- return `${indent}${condType} selector "${selector}" ${operation}`;
1616
+ return `${indent}${condType} selector \`${selector}\` ${operation}`;
1612
1617
  } else if (condition.domAssert.kind === "Text") {
1613
- return `${indent}${condType} selector "${selector}" text ${condition.comparison} ${formatValue(condition.value)}`;
1618
+ return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${formatValue(condition.value)}`;
1614
1619
  } else if (condition.domAssert.kind === "Count") {
1615
- return `${indent}${condType} selector "${selector}" count ${condition.comparison} ${condition.value}`;
1620
+ return `${indent}${condType} selector \`${selector}\` count ${condition.comparison} ${condition.value}`;
1616
1621
  } else if (condition.domAssert.kind === "Attribute") {
1617
- return `${indent}${condType} selector "${selector}" attribute "${condition.domAssert.name}" ${condition.comparison} ${formatValue(condition.value)}`;
1622
+ return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${formatValue(condition.value)}`;
1618
1623
  }
1619
1624
  }
1620
1625
  const fieldPart = condition.headerName ? `${condition.field} "${condition.headerName}"` : condition.jqExpr ? `${condition.field} \`${condition.jqExpr}\`` : condition.field;
@@ -1627,24 +1632,33 @@ function printTest(test) {
1627
1632
  test.mocks.forEach((mock) => {
1628
1633
  lines.push(printMock(mock, " "));
1629
1634
  });
1630
- lines.push(` when ${formatWhen(test.when)}`);
1631
- if (test.variables) {
1635
+ if (test.variables && test.variables.length > 0) {
1632
1636
  test.variables.forEach((variable) => {
1633
1637
  const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
1634
1638
  lines.push(` let ${variable.name} = ${formattedValue}`);
1635
1639
  });
1640
+ lines.push("");
1636
1641
  }
1637
- if (test.input) {
1638
- lines.push(` with input \`${test.input}\``);
1642
+ lines.push(` when ${formatWhen(test.when)}`);
1643
+ let hasWithClause = false;
1644
+ if (test.headers) {
1645
+ lines.push(` with headers \`${test.headers}\``);
1646
+ hasWithClause = true;
1639
1647
  }
1640
1648
  if (test.body) {
1641
- lines.push(` with body \`${test.body}\``);
1649
+ const prefix = hasWithClause ? "and with" : "with";
1650
+ lines.push(` ${prefix} body \`${test.body}\``);
1651
+ hasWithClause = true;
1642
1652
  }
1643
- if (test.headers) {
1644
- lines.push(` with headers \`${test.headers}\``);
1653
+ if (test.input) {
1654
+ const prefix = hasWithClause ? "and with" : "with";
1655
+ lines.push(` ${prefix} input \`${test.input}\``);
1656
+ hasWithClause = true;
1645
1657
  }
1646
1658
  if (test.cookies) {
1647
- lines.push(` with cookies \`${test.cookies}\``);
1659
+ const prefix = hasWithClause ? "and with" : "with";
1660
+ lines.push(` ${prefix} cookies \`${test.cookies}\``);
1661
+ hasWithClause = true;
1648
1662
  }
1649
1663
  test.conditions.forEach((condition) => {
1650
1664
  lines.push(printCondition(condition));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.42",
3
+ "version": "2.0.44",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",