@@ -39,6 +39,66 @@ describe('rendering React components at document', function() {
3939 testDocument = getTestDocument ( ) ;
4040 } ) ;
4141
42+ it ( 'should be able to get root component id for document node' , function ( ) {
43+ if ( ! testDocument ) {
44+ // These tests are not applicable in jst, since jsdom is buggy.
45+ return ;
46+ }
47+
48+ var Root = React . createClass ( {
49+ render : function ( ) {
50+ return (
51+ < html >
52+ < head >
53+ < title > Hello World</ title >
54+ </ head >
55+ < body >
56+ Hello world
57+ </ body >
58+ </ html >
59+ ) ;
60+ }
61+ } ) ;
62+
63+ ReactMount . allowFullPageRender = true ;
64+ var component = React . renderComponent ( < Root /> , testDocument ) ;
65+ expect ( testDocument . body . innerHTML ) . toBe ( ' Hello world ' ) ;
66+
67+ var componentID = ReactMount . getReactRootID ( testDocument ) ;
68+ expect ( componentID ) . toBe ( component . _rootNodeID ) ;
69+ } ) ;
70+
71+ it ( 'should be able to unmount component from document node' , function ( ) {
72+ if ( ! testDocument ) {
73+ // These tests are not applicable in jst, since jsdom is buggy.
74+ return ;
75+ }
76+
77+ var Root = React . createClass ( {
78+ render : function ( ) {
79+ return (
80+ < html >
81+ < head >
82+ < title > Hello World</ title >
83+ </ head >
84+ < body >
85+ Hello world
86+ </ body >
87+ </ html >
88+ ) ;
89+ }
90+ } ) ;
91+
92+ ReactMount . allowFullPageRender = true ;
93+ React . renderComponent ( < Root /> , testDocument ) ;
94+ expect ( testDocument . body . innerHTML ) . toBe ( ' Hello world ' ) ;
95+
96+ var unmounted = React . unmountComponentAtNode ( testDocument ) ;
97+ expect ( unmounted ) . toBe ( true ) ;
98+ expect ( testDocument . documentElement ) . not . toBe ( null ) ;
99+ expect ( testDocument . documentElement . innerHTML ) . toBe ( '' ) ;
100+ } ) ;
101+
42102 it ( 'should be able to switch root constructors via state' , function ( ) {
43103 if ( ! testDocument ) {
44104 // These tests are not applicable in jst, since jsdom is buggy.
0 commit comments