@@ -437,45 +437,70 @@ describe('formlyConfig', () => {
437
437
childFn = sinon . spy ( ) ;
438
438
} ) ;
439
439
440
- it ( `should call the parent validateOptions function when there is no child function` , ( ) => {
441
- setterFn ( [
442
- { name, template, validateOptions : parentFn } ,
443
- { name : 'type2' , extends : name }
444
- ] ) ;
445
- getterFn ( 'type2' ) . validateOptions ( options ) ;
446
- expect ( parentFn ) . to . have . been . calledWith ( options ) ;
440
+ it ( `should give a deprecation warning when specified as part of a type` , ( ) => {
441
+ shouldWarn (
442
+ / F o r m l y W a r n i n g : t h e ` v a l i d a t e O p t i o n s ` p r o p e r t y h a s b e e n d e p r e c a t e d . A t t e m p t e d f o r t y p e : f o o b a r / ,
443
+ function ( ) {
444
+ setterFn ( {
445
+ name : 'foobar' ,
446
+ validateOptions ( ) { }
447
+ } ) ;
448
+ }
449
+ ) ;
447
450
} ) ;
448
451
449
- it ( `should call the child validateOptions function when there is no parent function` , ( ) => {
450
- setterFn ( [
451
- { name, template} ,
452
- { name : 'type2' , extends : name , validateOptions : childFn }
453
- ] ) ;
454
- getterFn ( 'type2' ) . validateOptions ( options ) ;
455
- expect ( childFn ) . to . have . been . calledWith ( options ) ;
456
- } ) ;
452
+ describe ( `old functionality` , ( ) => {
453
+ let originalWarn ;
454
+ beforeEach ( ( ) => {
455
+ originalWarn = console . warn ;
456
+ console . warn = ( ) => { } ;
457
+ } ) ;
457
458
458
- it ( `should call the child validateOptions function and the parent validateOptions function when they are both present` , ( ) => {
459
- setterFn ( [
460
- { name, template, validateOptions : parentFn } ,
461
- { name : 'type2' , extends : name , validateOptions : childFn }
462
- ] ) ;
463
- getterFn ( 'type2' ) . validateOptions ( options ) ;
464
- expect ( childFn ) . to . have . been . calledWith ( options ) ;
465
- expect ( parentFn ) . to . have . been . calledWith ( options ) ;
466
- } ) ;
459
+ it ( `should call the parent validateOptions function when there is no child function` , ( ) => {
460
+ setterFn ( [
461
+ { name, template, validateOptions : parentFn } ,
462
+ { name : 'type2' , extends : name }
463
+ ] ) ;
464
+ getterFn ( 'type2' ) . validateOptions ( options ) ;
465
+ expect ( parentFn ) . to . have . been . calledWith ( options ) ;
466
+ } ) ;
467
467
468
- it ( `should pass the result of the child's defaultOptions with the given options to the parent's validateOptions function` , ( ) => {
469
- const defaultOptions = { data : { f : 'g' } } ;
470
- const combinedOptions = { data : { a : 'b' , c : { d : 'e' } , f : 'g' } } ;
471
- setterFn ( [
472
- { name, template, validateOptions : parentFn } ,
473
- { name : 'type2' , extends : name , validateOptions : childFn , defaultOptions}
474
- ] ) ;
475
- getterFn ( 'type2' ) . validateOptions ( options ) ;
476
- expect ( childFn ) . to . have . been . calledWith ( options ) ;
477
- expect ( parentFn ) . to . have . been . calledWith ( combinedOptions ) ;
468
+ it ( `should call the child validateOptions function when there is no parent function` , ( ) => {
469
+ setterFn ( [
470
+ { name, template} ,
471
+ { name : 'type2' , extends : name , validateOptions : childFn }
472
+ ] ) ;
473
+ getterFn ( 'type2' ) . validateOptions ( options ) ;
474
+ expect ( childFn ) . to . have . been . calledWith ( options ) ;
475
+ } ) ;
476
+
477
+ it ( `should call the child validateOptions function and the parent validateOptions function when they are both present` , ( ) => {
478
+ setterFn ( [
479
+ { name, template, validateOptions : parentFn } ,
480
+ { name : 'type2' , extends : name , validateOptions : childFn }
481
+ ] ) ;
482
+ getterFn ( 'type2' ) . validateOptions ( options ) ;
483
+ expect ( childFn ) . to . have . been . calledWith ( options ) ;
484
+ expect ( parentFn ) . to . have . been . calledWith ( options ) ;
485
+ } ) ;
486
+
487
+ it ( `should pass the result of the child's defaultOptions with the given options to the parent's validateOptions function` , ( ) => {
488
+ const defaultOptions = { data : { f : 'g' } } ;
489
+ const combinedOptions = { data : { a : 'b' , c : { d : 'e' } , f : 'g' } } ;
490
+ setterFn ( [
491
+ { name, template, validateOptions : parentFn } ,
492
+ { name : 'type2' , extends : name , validateOptions : childFn , defaultOptions}
493
+ ] ) ;
494
+ getterFn ( 'type2' ) . validateOptions ( options ) ;
495
+ expect ( childFn ) . to . have . been . calledWith ( options ) ;
496
+ expect ( parentFn ) . to . have . been . calledWith ( combinedOptions ) ;
497
+ } ) ;
498
+
499
+ afterEach ( ( ) => {
500
+ console . warn = originalWarn ;
501
+ } ) ;
478
502
} ) ;
503
+
479
504
} ) ;
480
505
481
506
describe ( `controller functions` , ( ) => {
@@ -519,23 +544,6 @@ describe('formlyConfig', () => {
519
544
520
545
} ) ;
521
546
} ) ;
522
-
523
- describe ( `validateOptions` , ( ) => {
524
- it ( `should allow you to specify this as a property of a type` , ( ) => {
525
- expect ( ( ) => {
526
- setterFn ( {
527
- name,
528
- validateOptions,
529
- template
530
- } ) ;
531
- } ) . to . not . throw ( ) ;
532
- expect ( getterFn ( name ) . validateOptions ) . to . be . a ( 'function' ) ;
533
-
534
- function validateOptions ( ) {
535
- }
536
- } ) ;
537
- } ) ;
538
-
539
547
} ) ;
540
548
541
549
describe ( '(◞‸◟;) path' , ( ) => {
@@ -601,7 +609,7 @@ describe('formlyConfig', () => {
601
609
602
610
it ( `should give a deprecation warning when providing apiCheck as an object rather than a function` , ( ) => {
603
611
shouldWarn (
604
- / F o r m l y W a r n i n g : a p i C h e c k a s a n o b j e c t h a s b e e n d e p r e c a t e d A t t e m p t e d f o r t y p e : i n p u t / ,
612
+ / F o r m l y W a r n i n g : a p i C h e c k a s a n o b j e c t h a s b e e n d e p r e c a t e d . A t t e m p t e d f o r t y p e : i n p u t / ,
605
613
function ( ) {
606
614
setterFn ( {
607
615
name,
0 commit comments