Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

fix: allow skip with object but no reason #318

Merged
merged 1 commit into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions js/src/utils/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ chai.use(dirtyChai)

module.exports.expect = chai.expect

const isObject = (o) => Object.prototype.toString.call(o) === '[object Object]'

// Get a "describe" function that is optionally 'skipped' or 'onlyed'
// If skip/only are boolean true, or an object with a reason property, then we
// want to skip/only the whole suite
Expand All @@ -16,7 +18,9 @@ function getDescribe (config) {
if (config.only === true) return describe.only
if (config.skip === true) return describe.skip

if (config.skip && typeof config.skip === 'object' && config.skip.reason) {
if (isObject(config.skip)) {
if (!config.skip.reason) return describe.skip

const _describe = (name, impl) => {
describe.skip(`${name} (${config.skip.reason})`, impl)
}
Expand Down Expand Up @@ -44,7 +48,7 @@ function getIt (config) {
const _it = (name, impl) => {
if (Array.isArray(config.skip)) {
const skip = config.skip
.map((s) => s && typeof s === 'object' ? s : { name: s })
.map((s) => isObject(s) ? s : { name: s })
.find((s) => s.name === name)

if (skip) {
Expand Down
4 changes: 3 additions & 1 deletion js/src/utils/suite.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const isObject = (o) => Object.prototype.toString.call(o) === '[object Object]'

function createSuite (tests, parent) {
const suite = (createCommon, options) => {
Object.keys(tests).forEach(t => {
Expand All @@ -8,7 +10,7 @@ function createSuite (tests, parent) {

if (Array.isArray(opts.skip)) {
const skip = opts.skip
.map((s) => s && typeof s === 'object' ? s : { name: s })
.map((s) => isObject(s) ? s : { name: s })
.find((s) => s.name === suiteName)

if (skip) {
Expand Down