Comparing version 2.0.0 to 2.0.1
@@ -1,5 +0,6 @@ | ||
import { vsprintf } from 'sprintf-js'; | ||
"use strict"; | ||
var _sprintfJs = require("sprintf-js"); | ||
module.exports = forEach; | ||
/** | ||
@@ -14,2 +15,3 @@ * Defines Mocha test cases for each given parameter. | ||
*/ | ||
function forEach(parameters, dIt = global.it, dDescribe = global.describe) { | ||
@@ -22,5 +24,7 @@ const it = makeTestCaseDefiner(parameters, dIt); | ||
describe.only = makeParameterizedOnly(parameters, dDescribe); | ||
return { it, describe }; | ||
return { | ||
it, | ||
describe | ||
}; | ||
} | ||
/** | ||
@@ -31,6 +35,7 @@ * Create a function which define parameterized tests | ||
*/ | ||
function makeParameterizedSkip(parameters, defaultIt) { | ||
return makeTestCaseDefiner(parameters, defaultIt ? defaultIt.skip : undefined); | ||
} | ||
/** | ||
@@ -40,2 +45,4 @@ * Create a function which define exclusive parameterized tests. | ||
*/ | ||
function makeParameterizedOnly(parameters, defaultIt) { | ||
@@ -47,3 +54,2 @@ return function (title, test) { | ||
} | ||
/** | ||
@@ -54,10 +60,10 @@ * Create a function which defines test cases for | ||
*/ | ||
function makeTestCaseDefiner(parameters, it) { | ||
return function defineTestCases(title, test) { | ||
const makeTitle = typeof title === 'function' ? title : (...args) => vsprintf(title, args); | ||
const makeTitle = typeof title === 'function' ? title : (...args) => (0, _sprintfJs.vsprintf)(title, args); | ||
const arrayParams = parameters.map(param => { | ||
return Array.isArray(param) ? param : [param]; | ||
}); | ||
const isAsync = isAsyncTest(arrayParams, test); | ||
@@ -69,3 +75,2 @@ arrayParams.forEach((param, index) => { | ||
} | ||
/** | ||
@@ -76,2 +81,4 @@ * Wrap a given test function and convert it to | ||
*/ | ||
function makeTestBody(param, test, isAsync) { | ||
@@ -83,2 +90,3 @@ if (isAsync) { | ||
} | ||
return function () { | ||
@@ -88,3 +96,2 @@ return test.apply(this, param); | ||
} | ||
/** | ||
@@ -94,2 +101,4 @@ * Return true if the testBody seems to be async. | ||
*/ | ||
function isAsyncTest(parameters, test) { | ||
@@ -96,0 +105,0 @@ const nLongestParam = parameters.reduce((n, param) => { |
@@ -0,1 +1,5 @@ | ||
## 2.0.1 (2019-06-27) | ||
- Fix broken build ([#10](https://github.com/ryym/mocha-each/pull/10)) | ||
## 2.0.0 (2019-06-22) | ||
@@ -2,0 +6,0 @@ |
{ | ||
"name": "mocha-each", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Parameterized test utility for Mocha", | ||
@@ -36,3 +36,3 @@ "main": "build/index.js", | ||
"@babel/core": "^7.4.5", | ||
"@babel/plugin-transform-modules-commonjs": "^7.4.4", | ||
"@babel/preset-env": "^7.4.5", | ||
"@babel/register": "^7.4.4", | ||
@@ -47,3 +47,3 @@ "babel-plugin-espower": "^3.0.1", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^6.1.2", | ||
"gulp-babel": "^8.0.0", | ||
"mocha": "^3.2.0", | ||
@@ -57,2 +57,3 @@ "nyc": "^10.2.0", | ||
"gulpfile.js", | ||
"build/*", | ||
"test/**/*" | ||
@@ -59,0 +60,0 @@ ] |
13897
171