From eb695a1c9136d1b1cb22e90a06c20dc574089059 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Fri, 17 Sep 2021 15:37:34 +0200 Subject: [PATCH] Fixed the tests --- theatre/core/src/propTypes/index.ts | 40 ++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/theatre/core/src/propTypes/index.ts b/theatre/core/src/propTypes/index.ts index 45b62ac..81ec872 100644 --- a/theatre/core/src/propTypes/index.ts +++ b/theatre/core/src/propTypes/index.ts @@ -143,7 +143,7 @@ export const number = ( )} given.`, ) } - if (typeof opts === 'object' && opts) { + if (typeof opts === 'object' && opts !== null) { if (Object.prototype.hasOwnProperty.call(opts, 'range')) { if (!Array.isArray(opts.range)) { throw new Error( @@ -163,26 +163,26 @@ export const number = ( ) } } - } - if (Object.prototype.hasOwnProperty.call(opts, 'nudgeMultiplier')) { - if ( - typeof opts!.nudgeMultiplier !== 'number' || - !isFinite(opts!.nudgeMultiplier) - ) { - throw new Error( - `opts.nudgeMultiplier in t.number(defaultValue, opts) must be a finite number. ${userReadableTypeOfValue( - opts!.nudgeMultiplier, - )} given.`, - ) + if (Object.prototype.hasOwnProperty.call(opts, 'nudgeMultiplier')) { + if ( + typeof opts!.nudgeMultiplier !== 'number' || + !isFinite(opts!.nudgeMultiplier) + ) { + throw new Error( + `opts.nudgeMultiplier in t.number(defaultValue, opts) must be a finite number. ${userReadableTypeOfValue( + opts!.nudgeMultiplier, + )} given.`, + ) + } } - } - if (Object.prototype.hasOwnProperty.call(opts, 'nudgeFn')) { - if (typeof opts?.nudgeFn !== 'function') { - throw new Error( - `opts.nudgeFn in t.number(defaultValue, opts) must be a function. ${userReadableTypeOfValue( - opts!.nudgeFn, - )} given.`, - ) + if (Object.prototype.hasOwnProperty.call(opts, 'nudgeFn')) { + if (typeof opts?.nudgeFn !== 'function') { + throw new Error( + `opts.nudgeFn in t.number(defaultValue, opts) must be a function. ${userReadableTypeOfValue( + opts!.nudgeFn, + )} given.`, + ) + } } } }