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

Commit

Permalink
fix: allow skip with object but no reason (#318)
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw authored Jul 2, 2018
1 parent b6bda46 commit ef91026
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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

0 comments on commit ef91026

Please sign in to comment.