@putout/test 7.6.0 → 7.7.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
@@ -209,7 +209,6 @@ test('test: no report after transform', (t) => {
209
209
  });
210
210
  ```
211
211
 
212
-
213
212
  ### `noReportAfterTransformWithOptions(filename)`
214
213
 
215
214
  Check error message of a plugin not produced with provided options:
@@ -2,7 +2,9 @@
2
2
 
3
3
  const isFn = (a) => typeof a === 'function';
4
4
 
5
- module.exports = (plugin) => {
5
+ module.exports.getIsCorrectPluginMessage = () => `should export 'replace', 'find', 'traverse', 'include', 'exclude', 'declare' or 'scan' function`;
6
+
7
+ module.exports.isCorrectPlugin = (plugin) => {
6
8
  const {
7
9
  find,
8
10
  fix,
@@ -11,6 +13,7 @@ module.exports = (plugin) => {
11
13
  exclude,
12
14
  replace,
13
15
  declare,
16
+ scan,
14
17
  } = plugin;
15
18
 
16
19
  const isFix = isFn(fix);
@@ -25,6 +28,9 @@ module.exports = (plugin) => {
25
28
  if (!isFix)
26
29
  return false;
27
30
 
31
+ if (isFn(scan))
32
+ return true;
33
+
28
34
  const isFind = isFn(find);
29
35
  const isTraverse = isFn(traverse);
30
36
 
package/lib/pre-test.js CHANGED
@@ -1,6 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const isCorrectPlugin = require('./is-correct-plugin');
3
+ const {
4
+ isCorrectPlugin,
5
+ getIsCorrectPluginMessage,
6
+ } = require('./is-correct-plugin');
7
+
4
8
  const {entries} = Object;
5
9
  const {isArray} = Array;
6
10
 
@@ -23,6 +27,7 @@ module.exports.preTest = function preTest(test, plugin) {
23
27
  filter,
24
28
  match,
25
29
  declare,
30
+ scan,
26
31
  }] = maybeEntries(plugin);
27
32
 
28
33
  const options = {
@@ -54,7 +59,7 @@ module.exports.preTest = function preTest(test, plugin) {
54
59
  t.end();
55
60
  }, options);
56
61
 
57
- test(`${name}: plugins should be of type: replace, template, traverse or find`, (t) => {
62
+ test(`${name}: plugins should be of type: Replacer, Includer, Traverser, Scanner, Declarator or Finder`, (t) => {
58
63
  const result = isCorrectPlugin({
59
64
  find,
60
65
  fix,
@@ -69,9 +74,10 @@ module.exports.preTest = function preTest(test, plugin) {
69
74
  replace,
70
75
 
71
76
  declare,
77
+ scan,
72
78
  });
73
79
 
74
- t.ok(result, `should export 'replace', 'find', 'traverse', 'include', 'exclude', or 'declare' function`);
80
+ t.ok(result, getIsCorrectPluginMessage());
75
81
  t.end();
76
82
  }, options);
77
83
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "7.6.0",
3
+ "version": "7.7.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "Test runner for 🐊Putout plugins ",