528
if (ReactDOMFeatureFlags.useFiber) {
529
// with Fiber, there are just three separate text node children,
530
// each of which is blank.
531
- expect(e.childNodes.length).toBe(3);
532
- expectTextNode(e.childNodes[0], '');
533
- expectTextNode(e.childNodes[1], '');
534
- expectTextNode(e.childNodes[2], '');
531
+ if (render === serverRender) {
532
+ // For plain server markup result we expect six comment nodes.
533
+ expect(e.childNodes.length).toBe(6);
534
+ expect(e.textContent).toBe('');
535
+ } else {
536
+ expect(e.childNodes.length).toBe(3);
537
+ expectTextNode(e.childNodes[0], '');
538
+ expectTextNode(e.childNodes[1], '');
539
+ expectTextNode(e.childNodes[2], '');
540
+ }
541
} else {
542
// with Stack, there are six react-text comment nodes.
543
expect(e.childNodes.length).toBe(6);
551
const e = await render(<div>{' '}{' '}{' '}</div>);
552
if (ReactDOMFeatureFlags.useFiber) {
553
// with Fiber, there are just three text nodes.
548
- expect(e.childNodes.length).toBe(3);
549
- expectTextNode(e.childNodes[0], ' ');
550
- expectTextNode(e.childNodes[1], ' ');
551
- expectTextNode(e.childNodes[2], ' ');
554
+ if (render === serverRender) {
555
+ expect(e.childNodes.length).toBe(9);
556
+ expectTextNode(e.childNodes[1], ' ');
557
+ expectTextNode(e.childNodes[4], ' ');
558
+ expectTextNode(e.childNodes[7], ' ');
559
+ } else {
560
+ expect(e.childNodes.length).toBe(3);
561
+ expectTextNode(e.childNodes[0], ' ');
562
+ expectTextNode(e.childNodes[1], ' ');
563
+ expectTextNode(e.childNodes[2], ' ');
564
+ }
565
} else {
566
// with Stack, each of the text nodes is surrounded by react-text
567
// comment nodes, making 9 nodes in total.
575
itRenders('a div with text sibling to a node', async render => {
576
const e = await render(<div>Text<span>More Text</span></div>);
577
let spanNode;
565
- if (ReactDOMFeatureFlags.useFiber) {
578
+ if (ReactDOMFeatureFlags.useFiber && render !== serverRender) {
579
// with Fiber, there are only two children, the "Text" text node and
580
// the span element.
581
expect(e.childNodes.length).toBe(2);
586
expect(e.childNodes.length).toBe(4);
587
spanNode = e.childNodes[3];
588
}
576
- expectTextNode(e.childNodes[0], 'Text');
589
+ if (ReactDOMFeatureFlags.useFiber && render === serverRender) {
590
+ expectTextNode(e.childNodes[1], 'Text');
591
+ } else {
592
+ expectTextNode(e.childNodes[0], 'Text');
593
+ }
594
expect(spanNode.tagName).toBe('SPAN');
595
expect(spanNode.childNodes.length).toBe(1);
596
expectNode(spanNode.firstChild, TEXT_NODE_TYPE, 'More Text');
614
const e = await render(<div>{''}foo</div>);
615
if (ReactDOMFeatureFlags.useFiber) {
616
// with Fiber, there are just two text nodes.
600
- expect(e.childNodes.length).toBe(2);
601
- expectTextNode(e.childNodes[0], '');
602
- expectTextNode(e.childNodes[1], 'foo');
617
+ if (render === serverRender) {
618
+ expect(e.childNodes.length).toBe(5);
619
+ expectTextNode(e.childNodes[3], 'foo');
620
+ } else {
621
+ expect(e.childNodes.length).toBe(2);
622
+ expectTextNode(e.childNodes[0], '');
623
+ expectTextNode(e.childNodes[1], 'foo');
624
+ }
625
} else {
626
// with Stack, there are five nodes: two react-text comment nodes
627
// without any text between them, and the text node foo surrounded
636
const e = await render(<div>foo{''}</div>);
637
if (ReactDOMFeatureFlags.useFiber) {
638
// with Fiber, there are just two text nodes.
617
- expect(e.childNodes.length).toBe(2);
618
- expectTextNode(e.childNodes[0], 'foo');
619
- expectTextNode(e.childNodes[1], '');
639
+ if (render === serverRender) {
640
+ expect(e.childNodes.length).toBe(5);
641
+ expectTextNode(e.childNodes[1], 'foo');
642
+ } else {
643
+ expect(e.childNodes.length).toBe(2);
644
+ expectTextNode(e.childNodes[0], 'foo');
645
+ expectTextNode(e.childNodes[1], '');
646
+ }
647
} else {
648
// with Stack, there are five nodes: the text node foo surrounded
649
// by react-text comment nodes, and two react-text comment nodes
658
const e = await render(<div>{'foo'}{'bar'}</div>);
659
if (ReactDOMFeatureFlags.useFiber) {
660
// with Fiber, there are just two text nodes.
634
- expect(e.childNodes.length).toBe(2);
635
- expectTextNode(e.childNodes[0], 'foo');
636
- expectTextNode(e.childNodes[1], 'bar');
661
+ if (render === serverRender) {
662
+ expect(e.childNodes.length).toBe(6);
663
+ expectTextNode(e.childNodes[1], 'foo');
664
+ expectTextNode(e.childNodes[4], 'bar');
665
+ } else {
666
+ expect(e.childNodes.length).toBe(2);
667
+ expectTextNode(e.childNodes[0], 'foo');
668
+ expectTextNode(e.childNodes[1], 'bar');
669
+ }
670
} else {
671
// with Stack, there are six nodes: two text nodes, each surrounded
672
// by react-text comment nodes.
693
const e = await render(<div>{'foo'}{40}</div>);
694
if (ReactDOMFeatureFlags.useFiber) {
695
// with Fiber, there are just two text nodes.
663
- expect(e.childNodes.length).toBe(2);
664
- expectTextNode(e.childNodes[0], 'foo');
665
- expectTextNode(e.childNodes[1], '40');
696
+ if (render === serverRender) {
697
+ expect(e.childNodes.length).toBe(6);
698
+ expectTextNode(e.childNodes[1], 'foo');
699
+ expectTextNode(e.childNodes[4], '40');
700
+ } else {
701
+ expect(e.childNodes.length).toBe(2);
702
+ expectTextNode(e.childNodes[0], 'foo');
703
+ expectTextNode(e.childNodes[1], '40');
704
+ }
705
} else {
706
// with Stack, there are six nodes: two text nodes, each surrounded
707
// by react-text comment nodes.
733
const e = await render(<div><NullComponent /></div>);
734
if (ReactDOMFeatureFlags.useFiber) {
735
// with Fiber, an empty component results in no markup.
697
- expect(e.childNodes.length).toBe(0);
736
+ if (render === serverRender) {
737
+ expect(e.childNodes.length).toBe(1);
738
+ expectEmptyNode(e.firstChild);
739
+ } else {
740
+ expect(e.childNodes.length).toBe(0);
741
+ }
742
} else {
743
// with Stack, an empty component results in one react-empty comment
744
// node.
751
const e = await render(<div>{null}foo</div>);
752
if (ReactDOMFeatureFlags.useFiber) {
753
// with Fiber, there is just one text node.
710
- expect(e.childNodes.length).toBe(1);
754
+ if (render === serverRender) {
755
+ expect(e.childNodes.length).toBe(3);
756
+ expectTextNode(e.childNodes[1], 'foo');
757
+ } else {
758
+ expect(e.childNodes.length).toBe(1);
759
+ expectTextNode(e.childNodes[0], 'foo');
760
+ }
761
} else {
762
// with Stack, there's a text node surronded by react-text comment nodes.
763
expect(e.childNodes.length).toBe(3);
764
+ expectTextNode(e.childNodes[0], 'foo');
765
}
715
- expectTextNode(e.childNodes[0], 'foo');
766
});
767
768
itRenders('false children as blank', async render => {
769
const e = await render(<div>{false}foo</div>);
770
if (ReactDOMFeatureFlags.useFiber) {
771
// with Fiber, there is just one text node.
722
- expect(e.childNodes.length).toBe(1);
772
+ if (render === serverRender) {
773
+ expect(e.childNodes.length).toBe(3);
774
+ expectTextNode(e.childNodes[1], 'foo');
775
+ } else {
776
+ expect(e.childNodes.length).toBe(1);
777
+ expectTextNode(e.childNodes[0], 'foo');
778
+ }
779
} else {
780
// with Stack, there's a text node surronded by react-text comment nodes.
781
expect(e.childNodes.length).toBe(3);
782
+ expectTextNode(e.childNodes[0], 'foo');
783
}
727
- expectTextNode(e.childNodes[0], 'foo');
784
});
785
786
itRenders('null and false children together as blank', async render => {
787
const e = await render(<div>{false}{null}foo{null}{false}</div>);
788
if (ReactDOMFeatureFlags.useFiber) {
789
// with Fiber, there is just one text node.
734
- expect(e.childNodes.length).toBe(1);
790
+ if (render === serverRender) {
791
+ expect(e.childNodes.length).toBe(3);
792
+ expectTextNode(e.childNodes[1], 'foo');
793
+ } else {
794
+ expect(e.childNodes.length).toBe(1);
795
+ expectTextNode(e.childNodes[0], 'foo');
796
+ }
797
} else {
798
// with Stack, there's a text node surronded by react-text comment nodes.
799
expect(e.childNodes.length).toBe(3);
800
+ expectTextNode(e.childNodes[0], 'foo');
801
}
739
- expectTextNode(e.childNodes[0], 'foo');
802
});
803
804
itRenders('only null and false children as blank', async render => {
992
if (ReactDOMFeatureFlags.useFiber) {
993
// with Fiber, there are three children: the child1 element, a
994
// single space text node, and the child2 element.
933
- expect(e.childNodes.length).toBe(3);
934
- child1 = e.childNodes[0];
935
- textNode = e.childNodes[1];
936
- child2 = e.childNodes[2];
995
+ if (render === serverRender) {
996
+ expect(e.childNodes.length).toBe(5);
997
+ child1 = e.childNodes[0];
998
+ textNode = e.childNodes[2];
999
+ child2 = e.childNodes[4];
1000
+ } else {
1001
+ expect(e.childNodes.length).toBe(3);
1002
+ child1 = e.childNodes[0];
1003
+ textNode = e.childNodes[1];
1004
+ child2 = e.childNodes[2];
1005
+ }
1006
} else {
1007
// with Stack, there are five children: the child1 element, a single
1008
// space surrounded by react-text comments, and the child2 element.
1028
if (ReactDOMFeatureFlags.useFiber) {
1029
// with Fiber, there are three children: a one-space text node, the
1030
// child element, and a two-space text node.
962
- expect(e.childNodes.length).toBe(3);
963
- textNode1 = e.childNodes[0];
964
- child = e.childNodes[1];
965
- textNode2 = e.childNodes[2];
1031
+ if (render === serverRender) {
1032
+ expect(e.childNodes.length).toBe(7);
1033
+ textNode1 = e.childNodes[1];
1034
+ child = e.childNodes[3];
1035
+ textNode2 = e.childNodes[5];
1036
+ } else {
1037
+ expect(e.childNodes.length).toBe(3);
1038
+ textNode1 = e.childNodes[0];
1039
+ child = e.childNodes[1];
1040
+ textNode2 = e.childNodes[2];
1041
+ }
1042
} else {
1043
// with Stack, there are 7 children: a one-space text node surrounded
1044
// by react-text comments, the child element, and a two-space text node
1070
);
1071
if (ReactDOMFeatureFlags.useFiber) {
1072
// with Fiber, there are just two text nodes.
997
- expect(e.childNodes.length).toBe(2);
998
- expectTextNode(e.childNodes[0], '<span>Text1"</span>');
999
- expectTextNode(e.childNodes[1], '<span>Text2"</span>');
1073
+ if (render === serverRender) {
1074
+ expect(e.childNodes.length).toBe(6);
1075
+ expectTextNode(e.childNodes[1], '<span>Text1"</span>');
1076
+ expectTextNode(e.childNodes[4], '<span>Text2"</span>');
1077
+ } else {
1078
+ expect(e.childNodes.length).toBe(2);
1079
+ expectTextNode(e.childNodes[0], '<span>Text1"</span>');
1080
+ expectTextNode(e.childNodes[1], '<span>Text2"</span>');
1081
+ }
1082
} else {
1083
// with Stack there are six nodes: two text nodes each surrounded by
1084
// two react-text comment nodes.