jest-each
Advanced tools
Comparing version 24.0.0-alpha.4 to 24.0.0-alpha.5
@@ -123,3 +123,3 @@ 'use strict'; | ||
const error = new (_jestUtil || _load_jestUtil()).ErrorWithStack( | ||
'`.each` must be called with an Array or Tagged Template String.\n\n' + | ||
'`.each` must be called with an Array or Tagged Template Literal.\n\n' + | ||
`Instead was called with: ${(0, | ||
@@ -136,2 +136,32 @@ (_prettyFormat || _load_prettyFormat()).default)(tableArg, { | ||
} | ||
if (isTaggedTemplateLiteral(tableArg)) { | ||
if (isEmptyString(tableArg[0])) { | ||
const error = new (_jestUtil || _load_jestUtil()).ErrorWithStack( | ||
'Error: `.each` called with an empty Tagged Template Literal of table data.\n', | ||
eachBind | ||
); | ||
return cb(title, () => { | ||
throw error; | ||
}); | ||
} | ||
const error = new (_jestUtil || _load_jestUtil()).ErrorWithStack( | ||
'Error: `.each` called with a Tagged Template Literal with no data, remember to interpolate with ${expression} syntax.\n', | ||
eachBind | ||
); | ||
return cb(title, () => { | ||
throw error; | ||
}); | ||
} | ||
if (isEmptyTable(tableArg)) { | ||
const error = new (_jestUtil || _load_jestUtil()).ErrorWithStack( | ||
'Error: `.each` called with an empty Array of table data.\n', | ||
eachBind | ||
); | ||
return cb(title, () => { | ||
throw error; | ||
}); | ||
} | ||
const table = tableArg.every(Array.isArray) | ||
@@ -193,2 +223,6 @@ ? tableArg | ||
const isTaggedTemplateLiteral = array => array.raw !== undefined; | ||
const isEmptyTable = table => table.length === 0; | ||
const isEmptyString = str => typeof str === 'string' && str.trim() === ''; | ||
const getPrettyIndexes = placeholders => | ||
@@ -195,0 +229,0 @@ placeholders.reduce( |
{ | ||
"name": "jest-each", | ||
"version": "24.0.0-alpha.4", | ||
"version": "24.0.0-alpha.5", | ||
"description": "Parameterised tests for Jest", | ||
@@ -20,4 +20,4 @@ "main": "build/index.js", | ||
"chalk": "^2.0.1", | ||
"jest-util": "^24.0.0-alpha.4", | ||
"pretty-format": "^24.0.0-alpha.4" | ||
"jest-util": "^24.0.0-alpha.5", | ||
"pretty-format": "^24.0.0-alpha.5" | ||
}, | ||
@@ -27,3 +27,3 @@ "engines": { | ||
}, | ||
"gitHead": "e41f0bb257c6652c3100b97a1087f9f812fbea0d" | ||
"gitHead": "2c18a53e8ff2437bba5fcb8076b754ac5f79f9f8" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24869
411
Updatedjest-util@^24.0.0-alpha.5