@@ -293,7 +293,7 @@ describe('prop', function () {
293293 } )
294294
295295 describe ( 'assertions' , function ( ) {
296- function makeInstance ( value , type , validator , coerce ) {
296+ function makeInstance ( value , type , validator , coerce , required ) {
297297 return new Vue ( {
298298 el : document . createElement ( 'div' ) ,
299299 template : '<test :test="val"></test>' ,
@@ -306,7 +306,8 @@ describe('prop', function () {
306306 test : {
307307 type : type ,
308308 validator : validator ,
309- coerce : coerce
309+ coerce : coerce ,
310+ required : required
310311 }
311312 }
312313 }
@@ -415,6 +416,22 @@ describe('prop', function () {
415416 } )
416417 expect ( hasWarned ( 'Missing required prop' ) ) . toBe ( true )
417418 } )
419+
420+ it ( 'optional with type + null/undefined' , function ( ) {
421+ makeInstance ( undefined , String )
422+ expect ( getWarnCount ( ) ) . toBe ( 0 )
423+ makeInstance ( null , String )
424+ expect ( getWarnCount ( ) ) . toBe ( 0 )
425+ } )
426+
427+ it ( 'required with type + null/undefined' , function ( ) {
428+ makeInstance ( undefined , String , null , null , true )
429+ expect ( getWarnCount ( ) ) . toBe ( 1 )
430+ expect ( hasWarned ( 'Expected String' ) ) . toBe ( true )
431+ makeInstance ( null , Boolean , null , null , true )
432+ expect ( getWarnCount ( ) ) . toBe ( 2 )
433+ expect ( hasWarned ( 'Expected Boolean' ) ) . toBe ( true )
434+ } )
418435 } )
419436
420437 it ( 'alternative syntax' , function ( ) {
0 commit comments