This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ chai.use(dirtyChai)
8
8
9
9
module . exports . expect = chai . expect
10
10
11
+ const isObject = ( o ) => Object . prototype . toString . call ( o ) === '[object Object]'
12
+
11
13
// Get a "describe" function that is optionally 'skipped' or 'onlyed'
12
14
// If skip/only are boolean true, or an object with a reason property, then we
13
15
// want to skip/only the whole suite
@@ -16,7 +18,9 @@ function getDescribe (config) {
16
18
if ( config . only === true ) return describe . only
17
19
if ( config . skip === true ) return describe . skip
18
20
19
- if ( config . skip && typeof config . skip === 'object' && config . skip . reason ) {
21
+ if ( isObject ( config . skip ) ) {
22
+ if ( ! config . skip . reason ) return describe . skip
23
+
20
24
const _describe = ( name , impl ) => {
21
25
describe . skip ( `${ name } (${ config . skip . reason } )` , impl )
22
26
}
@@ -44,7 +48,7 @@ function getIt (config) {
44
48
const _it = ( name , impl ) => {
45
49
if ( Array . isArray ( config . skip ) ) {
46
50
const skip = config . skip
47
- . map ( ( s ) => s && typeof s === 'object' ? s : { name : s } )
51
+ . map ( ( s ) => isObject ( s ) ? s : { name : s } )
48
52
. find ( ( s ) => s . name === name )
49
53
50
54
if ( skip ) {
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
+ const isObject = ( o ) => Object . prototype . toString . call ( o ) === '[object Object]'
4
+
3
5
function createSuite ( tests , parent ) {
4
6
const suite = ( createCommon , options ) => {
5
7
Object . keys ( tests ) . forEach ( t => {
@@ -8,7 +10,7 @@ function createSuite (tests, parent) {
8
10
9
11
if ( Array . isArray ( opts . skip ) ) {
10
12
const skip = opts . skip
11
- . map ( ( s ) => s && typeof s === 'object' ? s : { name : s } )
13
+ . map ( ( s ) => isObject ( s ) ? s : { name : s } )
12
14
. find ( ( s ) => s . name === suiteName )
13
15
14
16
if ( skip ) {
You can’t perform that action at this time.
0 commit comments