File tree 2 files changed +17
-1
lines changed
test/unit/features/options
2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,12 @@ function assertType (value: any, type: Function): {
145
145
let valid
146
146
const expectedType = getType ( type )
147
147
if ( simpleCheckRE . test ( expectedType ) ) {
148
- valid = typeof value === expectedType . toLowerCase ( )
148
+ const t = typeof value
149
+ valid = t === expectedType . toLowerCase ( )
150
+ // for primitive wrapper objects
151
+ if ( ! valid && t === 'object' ) {
152
+ valid = value instanceof type
153
+ }
149
154
} else if ( expectedType === 'Object' ) {
150
155
valid = isPlainObject ( value )
151
156
} else if ( expectedType === 'Array' ) {
Original file line number Diff line number Diff line change @@ -206,6 +206,17 @@ describe('Options props', () => {
206
206
expect ( 'Expected Array' ) . toHaveBeenWarned ( )
207
207
} )
208
208
209
+ it ( 'primitive wrapper objects' , ( ) => {
210
+ /* eslint-disable no-new-wrappers */
211
+ makeInstance ( new String ( 's' ) , String )
212
+ expect ( console . error . calls . count ( ) ) . toBe ( 0 )
213
+ makeInstance ( new Number ( 1 ) , Number )
214
+ expect ( console . error . calls . count ( ) ) . toBe ( 0 )
215
+ makeInstance ( new Boolean ( true ) , Boolean )
216
+ expect ( console . error . calls . count ( ) ) . toBe ( 0 )
217
+ /* eslint-enable no-new-wrappers */
218
+ } )
219
+
209
220
if ( hasSymbol ) {
210
221
it ( 'symbol' , ( ) => {
211
222
makeInstance ( Symbol ( 'foo' ) , Symbol )
You can’t perform that action at this time.
0 commit comments