@putout/test 7.2.0 → 7.4.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.
Files changed (2) hide show
  1. package/lib/test.js +9 -13
  2. package/package.json +2 -2
package/lib/test.js CHANGED
@@ -21,6 +21,7 @@ const isObject = (a) => typeof a === 'object';
21
21
  const {isArray} = Array;
22
22
 
23
23
  const {keys, entries} = Object;
24
+ const maybeEntries = (a) => isArray(a) ? a : entries(a).pop();
24
25
 
25
26
  global.__putout_test_fs = {
26
27
  readFileSync,
@@ -82,6 +83,7 @@ const rmFixture = (name) => {
82
83
 
83
84
  module.exports = createTest;
84
85
  module.exports.createTest = createTest;
86
+ module.exports._maybeEntries = maybeEntries;
85
87
 
86
88
  const parsePlugin = (plugins) => {
87
89
  if (isArray(plugins))
@@ -222,7 +224,7 @@ const formatManySave = currify((dir, options, t) => async (formatter, names, for
222
224
  if (!isUpdate())
223
225
  return await runFormat(formatter, names, formatterOptions);
224
226
 
225
- const {existsSync, writeFileSync} = global.__putout_test_fs;
227
+ const {writeFileSync} = global.__putout_test_fs;
226
228
 
227
229
  if (!isArray(names))
228
230
  throw Error(`☝️ Looks like 'formatMany()' received 'names' with type: '${typeof names}', expected: 'array'`);
@@ -230,10 +232,7 @@ const formatManySave = currify((dir, options, t) => async (formatter, names, for
230
232
  const name = `${names.join('-')}-format.js`;
231
233
  const outputName = join(dir, name);
232
234
 
233
- if (!existsSync(outputName))
234
- writeFileSync(outputName, '');
235
-
236
- const {result} = await runFormat(formatter, names, options);
235
+ const {result} = await runFormat(formatter, names, formatterOptions);
237
236
 
238
237
  writeFileSync(outputName, result);
239
238
 
@@ -246,15 +245,12 @@ const formatSave = currify((dir, options, t) => async (formatter, name, formatte
246
245
  if (!isUpdate())
247
246
  return await runFormat(formatter, name, formatterOptions);
248
247
 
249
- const {existsSync, writeFileSync} = global.__putout_test_fs;
248
+ const {writeFileSync} = global.__putout_test_fs;
250
249
 
251
250
  const full = join(dir, name);
252
251
  const outputName = `${full}-format.js`;
253
252
 
254
- if (!existsSync(outputName))
255
- writeFileSync(outputName, '');
256
-
257
- const {result} = await runFormat(formatter, name, options);
253
+ const {result} = await runFormat(formatter, name, formatterOptions);
258
254
 
259
255
  writeFileSync(outputName, result);
260
256
 
@@ -549,7 +545,7 @@ function preTest(test, plugin) {
549
545
  filter,
550
546
  match,
551
547
  declare,
552
- }] = entries(plugin).pop();
548
+ }] = maybeEntries(plugin);
553
549
 
554
550
  const options = {
555
551
  checkDuplicates: false,
@@ -574,7 +570,7 @@ function preTest(test, plugin) {
574
570
 
575
571
  if (!declare)
576
572
  test(`${name}: report: is function`, (t) => {
577
- t.equal(typeof report, 'function', 'should export "report" function');
573
+ t.equal(typeof report, 'function', `should export 'report' function`);
578
574
  t.end();
579
575
  }, options);
580
576
 
@@ -595,7 +591,7 @@ function preTest(test, plugin) {
595
591
  declare,
596
592
  });
597
593
 
598
- t.ok(result, 'should export "replace", "find", "traverse", "include", "exclude", or "declare" function');
594
+ t.ok(result, `should export 'replace', 'find', 'traverse', 'include', 'exclude', or 'declare' function`);
599
595
  t.end();
600
596
  }, options);
601
597
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "7.2.0",
3
+ "version": "7.4.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 ",
@@ -65,7 +65,7 @@
65
65
  "c8": "^8.0.0",
66
66
  "eslint": "^8.0.1",
67
67
  "eslint-plugin-n": "^16.0.0",
68
- "eslint-plugin-putout": "^20.0.0",
68
+ "eslint-plugin-putout": "^21.0.0",
69
69
  "lerna": "^6.0.1",
70
70
  "madrun": "^9.0.0",
71
71
  "mock-require": "^3.0.3",