ftmocks-utils 1.3.5 → 1.3.6

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/match-utils.js +19 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ftmocks-utils",
3
- "version": "1.3.5",
3
+ "version": "1.3.6",
4
4
  "description": "Util functions for FtMocks",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,6 +1,12 @@
1
1
  const { compareMockToFetchRequest } = require("./compare-utils");
2
2
  const { getCompareRankMockToFetchRequest } = require("./rank-compare-utils");
3
- const { getMockDir, nameToFolder } = require("./common-utils");
3
+ const {
4
+ getMockDir,
5
+ nameToFolder,
6
+ createIdMap,
7
+ createMethodPathnameIdMap,
8
+ getMockKey,
9
+ } = require("./common-utils");
4
10
  const path = require("path");
5
11
  const fs = require("fs");
6
12
 
@@ -14,11 +20,23 @@ function getMatchingMockData({
14
20
  mode,
15
21
  }) {
16
22
  let served = false;
23
+ const testMockIdMap = createIdMap(testMockData);
17
24
  let matchedMocks =
18
25
  testMockData?.filter((mock) => {
19
26
  if (mock.fileContent.waitForPrevious && !served) {
20
27
  return false;
21
28
  }
29
+ if (mock.fileContent.waitFor) {
30
+ const waitForMocks = mock.fileContent.waitFor.filter(
31
+ (waitForMockId) => {
32
+ const waitForMock = testMockIdMap[waitForMockId];
33
+ return waitForMock && !waitForMock.fileContent.served;
34
+ }
35
+ );
36
+ if (waitForMocks.length > 0) {
37
+ return false;
38
+ }
39
+ }
22
40
  served = mock.fileContent.served;
23
41
  return compareMockToFetchRequest(mock, { url, options });
24
42
  }) || [];