supertape 6.8.2 → 6.9.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/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2021.09.25, v6.9.0
2
+
3
+ feature:
4
+ - (supertape) fail when couple t.end() operators found
5
+
6
+
1
7
  2021.09.25, v6.8.2
2
8
 
3
9
  feature:
package/lib/operators.mjs CHANGED
@@ -164,7 +164,11 @@ const initOperator = (runnerState) => (name) => {
164
164
 
165
165
  if (isAsync(fn))
166
166
  return async (...a) => {
167
- const [valid, end] = validateEnd(name, runnerState);
167
+ const [valid, end] = validateEnd({
168
+ name,
169
+ operators,
170
+ runnerState,
171
+ });
168
172
 
169
173
  if (!valid)
170
174
  return end;
@@ -174,7 +178,11 @@ const initOperator = (runnerState) => (name) => {
174
178
  };
175
179
 
176
180
  return (...a) => {
177
- const [valid, end] = validateEnd(name, runnerState);
181
+ const [valid, end] = validateEnd({
182
+ name,
183
+ operators,
184
+ runnerState,
185
+ });
178
186
 
179
187
  if (!valid)
180
188
  return end;
@@ -187,15 +195,27 @@ const initOperator = (runnerState) => (name) => {
187
195
  const VALID = true;
188
196
  const INVALID = false;
189
197
 
190
- function validateEnd(name, runnerState) {
198
+ function validateEnd({name, operators, runnerState}) {
199
+ const {
200
+ isEnded,
201
+ incAssertionsCount,
202
+ } = runnerState;
203
+
204
+ incAssertionsCount();
205
+
206
+ if (name === 'end' && isEnded())
207
+ return [INVALID, run(
208
+ 'fail',
209
+ runnerState,
210
+ operators.fail(`Cannot use a couple 't.end()' operators in one test`),
211
+ )];
212
+
191
213
  if (name === 'end') {
192
- runnerState.isEnded(true);
214
+ isEnded(true);
193
215
  return [INVALID, end];
194
216
  }
195
217
 
196
- runnerState.incAssertionsCount();
197
-
198
- if (runnerState.isEnded()) {
218
+ if (isEnded()) {
199
219
  return [INVALID, run(
200
220
  'fail',
201
221
  runnerState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supertape",
3
- "version": "6.8.2",
3
+ "version": "6.9.0",
4
4
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
5
5
  "description": "tape compatible test runner with superpowers",
6
6
  "homepage": "http://github.com/coderaiser/supertape",