@putout/plugin-tape 21.17.1 → 21.18.0

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.
@@ -14,15 +14,15 @@ const printNode = (a) => print(a, {
14
14
  }],
15
15
  });
16
16
 
17
- export const report = ({prev, prevPrev}) => {
18
- return `Use '${printNode(prev)}' before '${printNode(prevPrev)}'`;
17
+ export const report = ({prev, assertion}) => {
18
+ return `Use '${printNode(prev)}' before '${printNode(assertion)}'`;
19
19
  };
20
20
 
21
- export const fix = ({prev, prevPrev}) => {
21
+ export const fix = ({prev, assertion}) => {
22
22
  const prevNode = prev.node;
23
23
 
24
24
  remove(prev);
25
- insertBefore(prevPrev, prevNode);
25
+ insertBefore(assertion, prevNode);
26
26
  };
27
27
 
28
28
  export const traverse = ({push}) => ({
@@ -35,15 +35,27 @@ export const traverse = ({push}) => ({
35
35
  if (compare(prev, 't.__a(__args)'))
36
36
  return;
37
37
 
38
- const prevPrev = prev.getPrevSibling();
38
+ const assertion = findAssertion(prev);
39
39
 
40
- if (!compare(prevPrev, 't.__a(__args)'))
40
+ if (!assertion)
41
41
  return;
42
42
 
43
43
  push({
44
44
  path,
45
45
  prev,
46
- prevPrev,
46
+ assertion,
47
47
  });
48
48
  },
49
49
  });
50
+
51
+ function findAssertion(path) {
52
+ const prev = path.getPrevSibling();
53
+
54
+ if (compare(prev, 't.__a(__args)'))
55
+ return prev;
56
+
57
+ if (!prev.node)
58
+ return null;
59
+
60
+ return findAssertion(prev);
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "21.17.1",
3
+ "version": "21.18.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊Putout plugin helps with tests",