@@ -667,6 +667,94 @@ describe('debug', () => {
667
667
} ) ;
668
668
} ) ;
669
669
670
+ describe ( 'button nesting' , ( ) => {
671
+ it ( 'should not warn on a regular button' , ( ) => {
672
+ const Button = ( ) => < button > Hello world</ button > ;
673
+
674
+ render ( < Button /> , scratch ) ;
675
+ expect ( console . error ) . to . not . be . called ;
676
+ } ) ;
677
+
678
+ it ( 'should warn for nesting illegal dom-nodes under a button' , ( ) => {
679
+ const Button = ( ) => (
680
+ < button >
681
+ < button > Hello world</ button >
682
+ </ button >
683
+ ) ;
684
+
685
+ render ( < Button /> , scratch ) ;
686
+ expect ( console . error ) . to . be . calledOnce ;
687
+ } ) ;
688
+
689
+ it ( 'should warn for nesting illegal dom-nodes under a button as func' , ( ) => {
690
+ const ButtonChild = ( { children } ) => < button > { children } </ button > ;
691
+ const Button = ( ) => (
692
+ < button >
693
+ < ButtonChild > Hello world</ ButtonChild >
694
+ </ button >
695
+ ) ;
696
+
697
+ render ( < Button /> , scratch ) ;
698
+ expect ( console . error ) . to . be . calledOnce ;
699
+ } ) ;
700
+
701
+ it ( 'should not warn for nesting non-interactive content under a button' , ( ) => {
702
+ const Button = ( ) => (
703
+ < button >
704
+ < span > Hello </ span >
705
+ < a > World</ a >
706
+ </ button >
707
+ ) ;
708
+
709
+ render ( < Button /> , scratch ) ;
710
+ expect ( console . error ) . to . not . be . called ;
711
+ } ) ;
712
+ } ) ;
713
+
714
+ describe ( 'anchor nesting' , ( ) => {
715
+ it ( 'should not warn a regular anchor' , ( ) => {
716
+ const Anchor = ( ) => < a > Hello world</ a > ;
717
+
718
+ render ( < Anchor /> , scratch ) ;
719
+ expect ( console . error ) . to . not . be . called ;
720
+ } ) ;
721
+
722
+ it ( 'should warn for nesting illegal dom-nodes under an anchor' , ( ) => {
723
+ const Anchor = ( ) => (
724
+ < a >
725
+ < a > Hello world</ a >
726
+ </ a >
727
+ ) ;
728
+
729
+ render ( < Anchor /> , scratch ) ;
730
+ expect ( console . error ) . to . be . calledOnce ;
731
+ } ) ;
732
+
733
+ it ( 'should warn for nesting illegal dom-nodes under an anchor as func' , ( ) => {
734
+ const AnchorChild = ( { children } ) => < a > { children } </ a > ;
735
+ const Anchor = ( ) => (
736
+ < a >
737
+ < AnchorChild > Hello world</ AnchorChild >
738
+ </ a >
739
+ ) ;
740
+
741
+ render ( < Anchor /> , scratch ) ;
742
+ expect ( console . error ) . to . be . calledOnce ;
743
+ } ) ;
744
+
745
+ it ( 'should not warn for nesting non-interactive content under an anchor' , ( ) => {
746
+ const Anchor = ( ) => (
747
+ < a >
748
+ < span > Hello </ span >
749
+ < button > World</ button >
750
+ </ a >
751
+ ) ;
752
+
753
+ render ( < Anchor /> , scratch ) ;
754
+ expect ( console . error ) . to . not . be . called ;
755
+ } ) ;
756
+ } ) ;
757
+
670
758
describe ( 'PropTypes' , ( ) => {
671
759
beforeEach ( ( ) => {
672
760
resetPropWarnings ( ) ;
0 commit comments