webpipe-js 2.0.61 → 2.0.63

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
@@ -896,11 +896,22 @@ var Parser = class {
896
896
  const commentPos = this.pos;
897
897
  const comment = this.tryParse(() => this.parseStandaloneComment());
898
898
  if (comment) {
899
+ const lookAheadPos = this.pos;
899
900
  if (this.cur() === "\n") this.pos++;
900
- this.skipWhitespaceOnly();
901
+ while (true) {
902
+ this.skipWhitespaceOnly();
903
+ const nextComment = this.tryParse(() => this.parseStandaloneComment());
904
+ if (nextComment) {
905
+ if (this.cur() === "\n") this.pos++;
906
+ continue;
907
+ }
908
+ break;
909
+ }
901
910
  const hasFollowingStep = this.text.startsWith("|>", this.pos);
911
+ this.pos = lookAheadPos;
902
912
  if (hasFollowingStep || steps.length === 0) {
903
913
  comments.push(comment);
914
+ if (this.cur() === "\n") this.pos++;
904
915
  continue;
905
916
  } else {
906
917
  this.pos = commentPos;
@@ -933,11 +944,22 @@ var Parser = class {
933
944
  const commentPos = this.pos;
934
945
  const comment = this.tryParse(() => this.parseStandaloneComment());
935
946
  if (comment) {
947
+ const lookAheadPos = this.pos;
936
948
  if (this.cur() === "\n") this.pos++;
937
- this.skipWhitespaceOnly();
949
+ while (true) {
950
+ this.skipWhitespaceOnly();
951
+ const nextComment = this.tryParse(() => this.parseStandaloneComment());
952
+ if (nextComment) {
953
+ if (this.cur() === "\n") this.pos++;
954
+ continue;
955
+ }
956
+ break;
957
+ }
938
958
  const hasFollowingStep = this.text.startsWith("|>", this.pos);
959
+ this.pos = lookAheadPos;
939
960
  if (hasFollowingStep || steps.length === 0) {
940
961
  comments.push(comment);
962
+ if (this.cur() === "\n") this.pos++;
941
963
  continue;
942
964
  } else {
943
965
  this.pos = commentPos;
@@ -1745,9 +1767,6 @@ function printCondition(condition, indent = " ") {
1745
1767
  function printTest(test) {
1746
1768
  const lines = [];
1747
1769
  lines.push(` it "${test.name}"`);
1748
- test.mocks.forEach((mock) => {
1749
- lines.push(printMock(mock, " "));
1750
- });
1751
1770
  if (test.variables && test.variables.length > 0) {
1752
1771
  test.variables.forEach((variable) => {
1753
1772
  const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
@@ -1757,18 +1776,25 @@ function printTest(test) {
1757
1776
  }
1758
1777
  lines.push(` when ${formatWhen(test.when)}`);
1759
1778
  let hasWithClause = false;
1760
- if (test.headers) {
1761
- lines.push(` with headers \`${test.headers}\``);
1779
+ if (test.input) {
1780
+ lines.push(` with input \`${test.input}\``);
1762
1781
  hasWithClause = true;
1763
1782
  }
1764
- if (test.body) {
1783
+ test.mocks.forEach((mock) => {
1784
+ const prefix = hasWithClause ? "and" : "with";
1785
+ const mockLine = printMock(mock, " ");
1786
+ const mockContent = mockLine.trim().replace(/^(with|and)\s+/, "");
1787
+ lines.push(` ${prefix} ${mockContent}`);
1788
+ hasWithClause = true;
1789
+ });
1790
+ if (test.headers) {
1765
1791
  const prefix = hasWithClause ? "and with" : "with";
1766
- lines.push(` ${prefix} body \`${test.body}\``);
1792
+ lines.push(` ${prefix} headers \`${test.headers}\``);
1767
1793
  hasWithClause = true;
1768
1794
  }
1769
- if (test.input) {
1795
+ if (test.body) {
1770
1796
  const prefix = hasWithClause ? "and with" : "with";
1771
- lines.push(` ${prefix} input \`${test.input}\``);
1797
+ lines.push(` ${prefix} body \`${test.body}\``);
1772
1798
  hasWithClause = true;
1773
1799
  }
1774
1800
  if (test.cookies) {
package/dist/index.mjs CHANGED
@@ -843,11 +843,22 @@ var Parser = class {
843
843
  const commentPos = this.pos;
844
844
  const comment = this.tryParse(() => this.parseStandaloneComment());
845
845
  if (comment) {
846
+ const lookAheadPos = this.pos;
846
847
  if (this.cur() === "\n") this.pos++;
847
- this.skipWhitespaceOnly();
848
+ while (true) {
849
+ this.skipWhitespaceOnly();
850
+ const nextComment = this.tryParse(() => this.parseStandaloneComment());
851
+ if (nextComment) {
852
+ if (this.cur() === "\n") this.pos++;
853
+ continue;
854
+ }
855
+ break;
856
+ }
848
857
  const hasFollowingStep = this.text.startsWith("|>", this.pos);
858
+ this.pos = lookAheadPos;
849
859
  if (hasFollowingStep || steps.length === 0) {
850
860
  comments.push(comment);
861
+ if (this.cur() === "\n") this.pos++;
851
862
  continue;
852
863
  } else {
853
864
  this.pos = commentPos;
@@ -880,11 +891,22 @@ var Parser = class {
880
891
  const commentPos = this.pos;
881
892
  const comment = this.tryParse(() => this.parseStandaloneComment());
882
893
  if (comment) {
894
+ const lookAheadPos = this.pos;
883
895
  if (this.cur() === "\n") this.pos++;
884
- this.skipWhitespaceOnly();
896
+ while (true) {
897
+ this.skipWhitespaceOnly();
898
+ const nextComment = this.tryParse(() => this.parseStandaloneComment());
899
+ if (nextComment) {
900
+ if (this.cur() === "\n") this.pos++;
901
+ continue;
902
+ }
903
+ break;
904
+ }
885
905
  const hasFollowingStep = this.text.startsWith("|>", this.pos);
906
+ this.pos = lookAheadPos;
886
907
  if (hasFollowingStep || steps.length === 0) {
887
908
  comments.push(comment);
909
+ if (this.cur() === "\n") this.pos++;
888
910
  continue;
889
911
  } else {
890
912
  this.pos = commentPos;
@@ -1692,9 +1714,6 @@ function printCondition(condition, indent = " ") {
1692
1714
  function printTest(test) {
1693
1715
  const lines = [];
1694
1716
  lines.push(` it "${test.name}"`);
1695
- test.mocks.forEach((mock) => {
1696
- lines.push(printMock(mock, " "));
1697
- });
1698
1717
  if (test.variables && test.variables.length > 0) {
1699
1718
  test.variables.forEach((variable) => {
1700
1719
  const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
@@ -1704,18 +1723,25 @@ function printTest(test) {
1704
1723
  }
1705
1724
  lines.push(` when ${formatWhen(test.when)}`);
1706
1725
  let hasWithClause = false;
1707
- if (test.headers) {
1708
- lines.push(` with headers \`${test.headers}\``);
1726
+ if (test.input) {
1727
+ lines.push(` with input \`${test.input}\``);
1709
1728
  hasWithClause = true;
1710
1729
  }
1711
- if (test.body) {
1730
+ test.mocks.forEach((mock) => {
1731
+ const prefix = hasWithClause ? "and" : "with";
1732
+ const mockLine = printMock(mock, " ");
1733
+ const mockContent = mockLine.trim().replace(/^(with|and)\s+/, "");
1734
+ lines.push(` ${prefix} ${mockContent}`);
1735
+ hasWithClause = true;
1736
+ });
1737
+ if (test.headers) {
1712
1738
  const prefix = hasWithClause ? "and with" : "with";
1713
- lines.push(` ${prefix} body \`${test.body}\``);
1739
+ lines.push(` ${prefix} headers \`${test.headers}\``);
1714
1740
  hasWithClause = true;
1715
1741
  }
1716
- if (test.input) {
1742
+ if (test.body) {
1717
1743
  const prefix = hasWithClause ? "and with" : "with";
1718
- lines.push(` ${prefix} input \`${test.input}\``);
1744
+ lines.push(` ${prefix} body \`${test.body}\``);
1719
1745
  hasWithClause = true;
1720
1746
  }
1721
1747
  if (test.cookies) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.61",
3
+ "version": "2.0.63",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",