@putout/plugin-tape 9.1.0 → 9.2.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.
package/README.md CHANGED
@@ -3,7 +3,11 @@
3
3
  [NPMIMGURL]: https://img.shields.io/npm/v/@putout/plugin-tape.svg?style=flat&longCache=true
4
4
  [NPMURL]: https://npmjs.org/package/@putout/plugin-tape"npm"
5
5
 
6
- 🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps to apply best parctises for tests written with 📼[`Supertape`](https://github.com/coderaiser/supertape).
6
+ > Tape-inspired TAP-compatible simplest high speed test runner with superpowers.
7
+ >
8
+ > (c) 📼[**Supertape**](https://github.com/coderaiser/supertape)
9
+
10
+ 🐊[**Putout**](https://github.com/coderaiser/putout) plugin helps to apply best parctises for tests written with 📼[**Supertape**](https://github.com/coderaiser/supertape).
7
11
 
8
12
  ## Install
9
13
 
@@ -57,13 +57,7 @@ function checkStub(node, path) {
57
57
  const {name} = node;
58
58
  const binding = bindings[name];
59
59
 
60
- if (!binding)
61
- return false;
62
-
63
- const initPath = binding.path.get('init');
64
- const calleePath = initPath.get('callee');
65
-
66
- return !calleePath.isMemberExpression();
60
+ return binding;
67
61
  }
68
62
 
69
63
  function applyWithNameToNode(node, path) {
@@ -76,9 +70,12 @@ function applyWithNameToNode(node, path) {
76
70
 
77
71
  const initPath = binding.path.get('init');
78
72
  const calleePath = initPath.get('callee');
73
+ const str = initPath.toString();
79
74
 
80
- if (calleePath.isMemberExpression())
75
+ if (calleePath.isMemberExpression() && !str.includes('withName')) {
76
+ replaceWith(initPath, template.ast(`${initPath}.withName('${name}')`));
81
77
  return;
78
+ }
82
79
 
83
80
  replaceWith(initPath, template.ast(`stub().withName('${name}')`));
84
81
  }
@@ -54,6 +54,7 @@ function match({__body}) {
54
54
 
55
55
  return false;
56
56
  }
57
+
57
58
  function replace({__a}, path) {
58
59
  declareOnce(path);
59
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-tape",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "putout plugin helps with tests",