webpipe-js 2.0.45 → 2.0.47
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 +21 -17
- package/dist/index.mjs +21 -17
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1602,11 +1602,10 @@ function printVariable(variable) {
|
|
|
1602
1602
|
return variableLine;
|
|
1603
1603
|
}
|
|
1604
1604
|
function printGraphQLSchema(schema) {
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
return schemaLine;
|
|
1605
|
+
const firstLine = schema.inlineComment ? `graphqlSchema = \` ${printComment(schema.inlineComment)}` : "graphqlSchema = `";
|
|
1606
|
+
return `${firstLine}
|
|
1607
|
+
${schema.sdl}
|
|
1608
|
+
\``;
|
|
1610
1609
|
}
|
|
1611
1610
|
function printQueryResolver(query) {
|
|
1612
1611
|
const lines = [];
|
|
@@ -1648,37 +1647,42 @@ function printTypeResolver(resolver) {
|
|
|
1648
1647
|
return lines.join("\n");
|
|
1649
1648
|
}
|
|
1650
1649
|
function printMock(mock, indent = " ") {
|
|
1651
|
-
const target = mock.target.replace(
|
|
1650
|
+
const target = mock.target.replace(/^(query|mutation)\.(.*)$/, "$1 $2");
|
|
1652
1651
|
return `${indent}with mock ${target} returning \`${mock.returnValue}\``;
|
|
1653
1652
|
}
|
|
1654
1653
|
function printCondition(condition, indent = " ") {
|
|
1655
1654
|
const condType = condition.conditionType.toLowerCase();
|
|
1655
|
+
const formatConditionValue = (val) => {
|
|
1656
|
+
if (val.startsWith("`") || val.startsWith('"')) return val;
|
|
1657
|
+
const isBareTemplate = /^\{\{[^}]+\}\}$/.test(val);
|
|
1658
|
+
if (isBareTemplate) return val;
|
|
1659
|
+
const hasTemplateVars = /\{\{[^}]+\}\}/.test(val);
|
|
1660
|
+
if (hasTemplateVars) return `"${val}"`;
|
|
1661
|
+
if (val.includes("\n") || val.includes("{") && val.includes("}") || val.includes("[") && val.includes("]")) {
|
|
1662
|
+
return `\`${val}\``;
|
|
1663
|
+
}
|
|
1664
|
+
if (val.includes(" ") || val.includes(",")) return `"${val}"`;
|
|
1665
|
+
return val;
|
|
1666
|
+
};
|
|
1656
1667
|
if (condition.isCallAssertion && condition.callTarget) {
|
|
1657
1668
|
const [callType, callName] = condition.callTarget.split(".");
|
|
1658
|
-
|
|
1659
|
-
return `${indent}${condType} call ${callType} ${callName} ${condition.comparison} ${value2}`;
|
|
1669
|
+
return `${indent}${condType} call ${callType} ${callName} ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1660
1670
|
}
|
|
1661
1671
|
if (condition.field === "selector" && condition.selector && condition.domAssert) {
|
|
1662
1672
|
const selector = condition.selector;
|
|
1663
|
-
const formatValue = (val) => {
|
|
1664
|
-
if (val.startsWith("`") || val.startsWith('"')) return val;
|
|
1665
|
-
if (val.includes("\n") || val.includes("{") || val.includes("[")) return `\`${val}\``;
|
|
1666
|
-
return `"${val}"`;
|
|
1667
|
-
};
|
|
1668
1673
|
if (condition.domAssert.kind === "Exists") {
|
|
1669
1674
|
const operation = condition.comparison === "exists" ? "exists" : "does not exist";
|
|
1670
1675
|
return `${indent}${condType} selector \`${selector}\` ${operation}`;
|
|
1671
1676
|
} else if (condition.domAssert.kind === "Text") {
|
|
1672
|
-
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${
|
|
1677
|
+
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1673
1678
|
} else if (condition.domAssert.kind === "Count") {
|
|
1674
1679
|
return `${indent}${condType} selector \`${selector}\` count ${condition.comparison} ${condition.value}`;
|
|
1675
1680
|
} else if (condition.domAssert.kind === "Attribute") {
|
|
1676
|
-
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${
|
|
1681
|
+
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1677
1682
|
}
|
|
1678
1683
|
}
|
|
1679
1684
|
const fieldPart = condition.headerName ? `${condition.field} "${condition.headerName}"` : condition.jqExpr ? `${condition.field} \`${condition.jqExpr}\`` : condition.field;
|
|
1680
|
-
|
|
1681
|
-
return `${indent}${condType} ${fieldPart} ${condition.comparison} ${value}`;
|
|
1685
|
+
return `${indent}${condType} ${fieldPart} ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1682
1686
|
}
|
|
1683
1687
|
function printTest(test) {
|
|
1684
1688
|
const lines = [];
|
package/dist/index.mjs
CHANGED
|
@@ -1549,11 +1549,10 @@ function printVariable(variable) {
|
|
|
1549
1549
|
return variableLine;
|
|
1550
1550
|
}
|
|
1551
1551
|
function printGraphQLSchema(schema) {
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
return schemaLine;
|
|
1552
|
+
const firstLine = schema.inlineComment ? `graphqlSchema = \` ${printComment(schema.inlineComment)}` : "graphqlSchema = `";
|
|
1553
|
+
return `${firstLine}
|
|
1554
|
+
${schema.sdl}
|
|
1555
|
+
\``;
|
|
1557
1556
|
}
|
|
1558
1557
|
function printQueryResolver(query) {
|
|
1559
1558
|
const lines = [];
|
|
@@ -1595,37 +1594,42 @@ function printTypeResolver(resolver) {
|
|
|
1595
1594
|
return lines.join("\n");
|
|
1596
1595
|
}
|
|
1597
1596
|
function printMock(mock, indent = " ") {
|
|
1598
|
-
const target = mock.target.replace(
|
|
1597
|
+
const target = mock.target.replace(/^(query|mutation)\.(.*)$/, "$1 $2");
|
|
1599
1598
|
return `${indent}with mock ${target} returning \`${mock.returnValue}\``;
|
|
1600
1599
|
}
|
|
1601
1600
|
function printCondition(condition, indent = " ") {
|
|
1602
1601
|
const condType = condition.conditionType.toLowerCase();
|
|
1602
|
+
const formatConditionValue = (val) => {
|
|
1603
|
+
if (val.startsWith("`") || val.startsWith('"')) return val;
|
|
1604
|
+
const isBareTemplate = /^\{\{[^}]+\}\}$/.test(val);
|
|
1605
|
+
if (isBareTemplate) return val;
|
|
1606
|
+
const hasTemplateVars = /\{\{[^}]+\}\}/.test(val);
|
|
1607
|
+
if (hasTemplateVars) return `"${val}"`;
|
|
1608
|
+
if (val.includes("\n") || val.includes("{") && val.includes("}") || val.includes("[") && val.includes("]")) {
|
|
1609
|
+
return `\`${val}\``;
|
|
1610
|
+
}
|
|
1611
|
+
if (val.includes(" ") || val.includes(",")) return `"${val}"`;
|
|
1612
|
+
return val;
|
|
1613
|
+
};
|
|
1603
1614
|
if (condition.isCallAssertion && condition.callTarget) {
|
|
1604
1615
|
const [callType, callName] = condition.callTarget.split(".");
|
|
1605
|
-
|
|
1606
|
-
return `${indent}${condType} call ${callType} ${callName} ${condition.comparison} ${value2}`;
|
|
1616
|
+
return `${indent}${condType} call ${callType} ${callName} ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1607
1617
|
}
|
|
1608
1618
|
if (condition.field === "selector" && condition.selector && condition.domAssert) {
|
|
1609
1619
|
const selector = condition.selector;
|
|
1610
|
-
const formatValue = (val) => {
|
|
1611
|
-
if (val.startsWith("`") || val.startsWith('"')) return val;
|
|
1612
|
-
if (val.includes("\n") || val.includes("{") || val.includes("[")) return `\`${val}\``;
|
|
1613
|
-
return `"${val}"`;
|
|
1614
|
-
};
|
|
1615
1620
|
if (condition.domAssert.kind === "Exists") {
|
|
1616
1621
|
const operation = condition.comparison === "exists" ? "exists" : "does not exist";
|
|
1617
1622
|
return `${indent}${condType} selector \`${selector}\` ${operation}`;
|
|
1618
1623
|
} else if (condition.domAssert.kind === "Text") {
|
|
1619
|
-
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${
|
|
1624
|
+
return `${indent}${condType} selector \`${selector}\` text ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1620
1625
|
} else if (condition.domAssert.kind === "Count") {
|
|
1621
1626
|
return `${indent}${condType} selector \`${selector}\` count ${condition.comparison} ${condition.value}`;
|
|
1622
1627
|
} else if (condition.domAssert.kind === "Attribute") {
|
|
1623
|
-
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${
|
|
1628
|
+
return `${indent}${condType} selector \`${selector}\` attribute "${condition.domAssert.name}" ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1624
1629
|
}
|
|
1625
1630
|
}
|
|
1626
1631
|
const fieldPart = condition.headerName ? `${condition.field} "${condition.headerName}"` : condition.jqExpr ? `${condition.field} \`${condition.jqExpr}\`` : condition.field;
|
|
1627
|
-
|
|
1628
|
-
return `${indent}${condType} ${fieldPart} ${condition.comparison} ${value}`;
|
|
1632
|
+
return `${indent}${condType} ${fieldPart} ${condition.comparison} ${formatConditionValue(condition.value)}`;
|
|
1629
1633
|
}
|
|
1630
1634
|
function printTest(test) {
|
|
1631
1635
|
const lines = [];
|