@putout/test 3.7.5 → 4.0.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 (3) hide show
  1. package/README.md +14 -13
  2. package/lib/test.js +18 -18
  3. package/package.json +9 -10
package/README.md CHANGED
@@ -1,11 +1,9 @@
1
- # @putout/test [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]
1
+ # @putout/test [![NPM version][NPMIMGURL]][NPMURL]
2
2
 
3
3
  [NPMIMGURL]: https://img.shields.io/npm/v/@putout/test.svg?style=flat&longCache=true
4
4
  [NPMURL]: https://npmjs.org/package/@putout/test "npm"
5
- [DependencyStatusURL]: https://david-dm.org/coderaiser/putout?path=packages/test-runner
6
- [DependencyStatusIMGURL]: https://david-dm.org/coderaiser/putout.svg?path=packages/test-runner
7
5
 
8
- Test runner for [`putout plugins`](https://github.com/coderaiser/putout#plugins-api). Basically it is [supercharged `tape`](https://github.com/coderaiser/supertape) with aditional asseritions:
6
+ Test runner for [🐊`Putout`](https://github.com/coderaiser/putout#plugins-api). Basically it is [supercharged `tape`](https://github.com/coderaiser/supertape) with aditional asseritions:
9
7
 
10
8
  ## Install
11
9
 
@@ -109,7 +107,6 @@ test('putout: plugin: declare-undefined-variables: transform: parse', (t) => {
109
107
  t.transformWithOptions('parse', {
110
108
  dismiss: ['assign', 'stringify'],
111
109
  });
112
-
113
110
  t.end();
114
111
  });
115
112
  ```
@@ -175,14 +172,19 @@ test('plugin-apply-numeric-separators: no transform: hex', (t) => {
175
172
 
176
173
  check file name formatting (pass `process.env.UPDATE=1` to save fixture)
177
174
 
175
+ ```js
176
+ test('formatter: codeframe', async ({format}) => {
177
+ await format(codeframe);
178
+ });
179
+ ```
180
+
178
181
  ### noFormat
179
182
 
180
183
  check that there is no formatting for for such file
181
184
 
182
185
  ```js
183
- test('formatter: codeframe: no', (t) => {
184
- t.noFormat(codeframe, 'no');
185
- t.end();
186
+ test('formatter: codeframe: no', async ({noFormat}) => {
187
+ await noFormat(codeframe, 'no');
186
188
  });
187
189
  ```
188
190
 
@@ -191,9 +193,8 @@ test('formatter: codeframe: no', (t) => {
191
193
  check file name formatting (pass `process.env.UPDATE=1` to save fixture)
192
194
 
193
195
  ```js
194
- test('formatter: dump: many', (t) => {
195
- t.formatMany(dump, ['var', 'var']);
196
- t.end();
196
+ test('formatter: dump: many', async ({formatMany}) => {
197
+ await formatMany(dump, ['var', 'var']);
197
198
  });
198
199
  ```
199
200
 
@@ -265,8 +266,8 @@ Check that filename would not be processed.
265
266
  Example:
266
267
 
267
268
  ```js
268
- test('putout: process: json: no process', async (t) => {
269
- await t.noProcess('eslintrc', [], ['json']);
269
+ test('putout: process: json: no process', async ({noProcess}) => {
270
+ await noProcess('eslintrc', [], ['json']);
270
271
  });
271
272
  ```
272
273
 
package/lib/test.js CHANGED
@@ -66,7 +66,7 @@ module.exports = (dir, plugin, rules) => {
66
66
  });
67
67
  };
68
68
 
69
- const format = currify(({dir, plugins, rules}, t, formatter, name, formatterOptions = {}) => {
69
+ const format = currify(({dir, plugins, rules}, t) => async (formatter, name, formatterOptions = {}) => {
70
70
  const full = join(dir, name);
71
71
  const outputName = `${full}-format`;
72
72
  const [input, isTS] = readFixture(full);
@@ -75,7 +75,7 @@ const format = currify(({dir, plugins, rules}, t, formatter, name, formatterOpti
75
75
  const {places} = putout(input, {fixCount: 1, isTS, plugins, rules});
76
76
 
77
77
  const report = putout.initReport();
78
- const result = report(formatter, {
78
+ const result = await report(formatter, {
79
79
  formatterOptions,
80
80
  name,
81
81
  source: input,
@@ -87,14 +87,14 @@ const format = currify(({dir, plugins, rules}, t, formatter, name, formatterOpti
87
87
  return {is, output, result};
88
88
  });
89
89
 
90
- const noFormat = currify(({dir, plugins, rules}, t, formatter, name, formatterOptions = {}) => {
90
+ const noFormat = currify(({dir, plugins, rules}, t) => async (formatter, name, formatterOptions = {}) => {
91
91
  const full = join(dir, name);
92
92
  const [input] = readFixture(full);
93
93
 
94
94
  const {places} = putout(input, {plugins, rules});
95
95
 
96
96
  const report = putout.initReport();
97
- const result = report(formatter, {
97
+ const result = await report(formatter, {
98
98
  name,
99
99
  places,
100
100
  formatterOptions,
@@ -105,7 +105,7 @@ const noFormat = currify(({dir, plugins, rules}, t, formatter, name, formatterOp
105
105
  return {is, output, result};
106
106
  });
107
107
 
108
- const formatMany = currify(({dir, plugins, rules}, t, formatter, names, formatterOptions = {}) => {
108
+ const formatMany = currify(({dir, plugins, rules}, t) => async (formatter, names, formatterOptions = {}) => {
109
109
  const joinTwo = (a) => (b) => join(a, b);
110
110
  const fullNames = names.map(joinTwo(dir));
111
111
 
@@ -124,7 +124,7 @@ const formatMany = currify(({dir, plugins, rules}, t, formatter, names, formatte
124
124
  rules,
125
125
  });
126
126
 
127
- result += report(formatter, {
127
+ result += await report(formatter, {
128
128
  name,
129
129
  formatterOptions,
130
130
  source: input,
@@ -142,44 +142,44 @@ const formatMany = currify(({dir, plugins, rules}, t, formatter, names, formatte
142
142
  return {is, output, result};
143
143
  });
144
144
 
145
- const formatManySave = currify(({dir, plugins, rules}, t, formatter, names, options = {}) => {
145
+ const formatManySave = currify(({dir, plugins, rules}, t) => async (formatter, names, options = {}) => {
146
146
  const name = `${names.join('-')}-format.js`;
147
147
  const outputName = join(dir, name);
148
148
 
149
149
  if (!existsSync(outputName))
150
150
  writeFileSync(outputName, '');
151
151
 
152
+ const runFormat = await formatMany({dir, plugins, rules}, t);
153
+
152
154
  const {
153
155
  is,
154
156
  output,
155
157
  result,
156
- } = formatMany({dir, plugins, rules}, t, formatter, names, options);
158
+ } = await runFormat(formatter, names, options);
157
159
 
158
160
  writeFileSync(outputName, result);
159
161
 
160
162
  return {is, output, result};
161
163
  });
162
164
 
163
- const formatSave = currify(({dir, plugins, rules}, t, formatter, name, options = {}) => {
165
+ const formatSave = currify(({dir, plugins, rules}, t) => async (formatter, name, options = {}) => {
164
166
  const full = join(dir, name);
165
167
  const outputName = `${full}-format.js`;
166
168
 
167
169
  if (!existsSync(outputName))
168
170
  writeFileSync(outputName, '');
169
171
 
172
+ const runFormat = format({
173
+ dir,
174
+ plugins,
175
+ rules,
176
+ }, t);
177
+
170
178
  const {
171
179
  is,
172
180
  output,
173
181
  result,
174
- } = format(
175
- {dir,
176
- plugins,
177
- rules},
178
- t,
179
- formatter,
180
- name,
181
- options,
182
- );
182
+ } = await runFormat(formatter, name, options);
183
183
 
184
184
  writeFileSync(outputName, result);
185
185
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/test",
3
- "version": "3.7.5",
3
+ "version": "4.0.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "test runner for putout plugins ",
6
6
  "homepage": "https://github.com/coderaiser/putout/tree/master/packages/test#readme",
@@ -44,18 +44,17 @@
44
44
  "runner"
45
45
  ],
46
46
  "devDependencies": {
47
- "@cloudcmd/stub": "^3.0.0",
48
- "@putout/formatter-dump": "^2.0.1",
49
- "@putout/formatter-progress": "^2.0.0",
50
- "@putout/plugin-extract-object-properties": "^6.0.1",
51
- "@putout/plugin-putout": "^7.2.0",
52
- "@putout/plugin-remove-console": "^3.1.0",
53
- "@putout/plugin-remove-empty": "^6.0.0",
47
+ "@putout/formatter-dump": "*",
48
+ "@putout/formatter-progress": "*",
49
+ "@putout/plugin-extract-object-properties": "*",
50
+ "@putout/plugin-putout": "*",
51
+ "@putout/plugin-remove-console": "*",
52
+ "@putout/plugin-remove-empty": "*",
54
53
  "@putout/plugin-remove-unused-variables": "*",
55
54
  "c8": "^7.5.0",
56
- "eslint": "^8.0.0-beta.0",
55
+ "eslint": "^8.0.1",
57
56
  "eslint-plugin-node": "^11.0.0",
58
- "eslint-plugin-putout": "^10.0.0",
57
+ "eslint-plugin-putout": "^12.0.0",
59
58
  "lerna": "^4.0.0",
60
59
  "madrun": "^8.0.1",
61
60
  "mock-require": "^3.0.3",