@@ -774,10 +774,18 @@ describe('suspense hydration', () => {
774774		} ) ; 
775775	} ) ; 
776776
777- 	// Currently not supported, but I wrote the test before I realized that so 
778- 	// leaving it here in case we do support it eventually 
777+ 	// TODO: this should start workign now but still bugged 
779778	it . skip ( 'should properly hydrate suspense when resolves to a Fragment' ,  ( )  =>  { 
780- 		const  originalHtml  =  ul ( [ li ( 0 ) ,  li ( 1 ) ,  li ( 2 ) ,  li ( 3 ) ,  li ( 4 ) ,  li ( 5 ) ] ) ; 
779+ 		const  originalHtml  =  ul ( [ 
780+ 			li ( 0 ) , 
781+ 			li ( 1 ) , 
782+ 			'<!--$s-->' , 
783+ 			li ( 2 ) , 
784+ 			li ( 3 ) , 
785+ 			'<!--/$s-->' , 
786+ 			li ( 4 ) , 
787+ 			li ( 5 ) 
788+ 		] ) ; 
781789
782790		const  listeners  =  [ 
783791			sinon . spy ( ) , 
@@ -809,8 +817,8 @@ describe('suspense hydration', () => {
809817			scratch 
810818		) ; 
811819		rerender ( ) ;  // Flush rerender queue to mimic what preact will really do 
812- 		expect ( scratch . innerHTML ) . to . equal ( originalHtml ) ; 
813820		expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
821+ 		expect ( scratch . innerHTML ) . to . equal ( originalHtml ) ; 
814822		expect ( listeners [ 5 ] ) . not . to . have . been . called ; 
815823
816824		clearLog ( ) ; 
@@ -839,4 +847,169 @@ describe('suspense hydration', () => {
839847			expect ( listeners [ 5 ] ) . to . have . been . calledTwice ; 
840848		} ) ; 
841849	} ) ; 
850+ 
851+ 	it ( 'Should hydrate a fragment with multiple children correctly' ,  ( )  =>  { 
852+ 		scratch . innerHTML  =  '<!--$s--><div>Hello</div><div>World!</div><!--/$s-->' ; 
853+ 		clearLog ( ) ; 
854+ 
855+ 		const  [ Lazy ,  resolve ]  =  createLazy ( ) ; 
856+ 		hydrate ( 
857+ 			< Suspense > 
858+ 				< Lazy  /> 
859+ 			</ Suspense > , 
860+ 			scratch 
861+ 		) ; 
862+ 		rerender ( ) ;  // Flush rerender queue to mimic what preact will really do 
863+ 		expect ( scratch . innerHTML ) . to . equal ( 
864+ 			'<!--$s--><div>Hello</div><div>World!</div><!--/$s-->' 
865+ 		) ; 
866+ 		expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
867+ 		clearLog ( ) ; 
868+ 
869+ 		return  resolve ( ( )  =>  ( 
870+ 			< > 
871+ 				< div > Hello</ div > 
872+ 				< div > World!</ div > 
873+ 			</ > 
874+ 		) ) . then ( ( )  =>  { 
875+ 			rerender ( ) ; 
876+ 			expect ( scratch . innerHTML ) . to . equal ( 
877+ 				'<!--$s--><div>Hello</div><div>World!</div><!--/$s-->' 
878+ 			) ; 
879+ 			expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
880+ 
881+ 			clearLog ( ) ; 
882+ 		} ) ; 
883+ 	} ) ; 
884+ 
885+ 	it ( 'Should hydrate a fragment with no children correctly' ,  ( )  =>  { 
886+ 		scratch . innerHTML  =  '<!--$s--><!--/$s--><div>Hello world</div>' ; 
887+ 		clearLog ( ) ; 
888+ 
889+ 		const  [ Lazy ,  resolve ]  =  createLazy ( ) ; 
890+ 		hydrate ( 
891+ 			< > 
892+ 				< Suspense > 
893+ 					< Lazy  /> 
894+ 				</ Suspense > 
895+ 				< div > Hello world</ div > 
896+ 			</ > , 
897+ 			scratch 
898+ 		) ; 
899+ 		rerender ( ) ;  // Flush rerender queue to mimic what preact will really do 
900+ 		expect ( scratch . innerHTML ) . to . equal ( 
901+ 			'<!--$s--><!--/$s--><div>Hello world</div>' 
902+ 		) ; 
903+ 		expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
904+ 		clearLog ( ) ; 
905+ 
906+ 		return  resolve ( ( )  =>  null ) . then ( ( )  =>  { 
907+ 			rerender ( ) ; 
908+ 			expect ( scratch . innerHTML ) . to . equal ( 
909+ 				'<!--$s--><!--/$s--><div>Hello world</div>' 
910+ 			) ; 
911+ 			expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
912+ 
913+ 			clearLog ( ) ; 
914+ 		} ) ; 
915+ 	} ) ; 
916+ 
917+ 	it ( 'Should hydrate a fragment with no children correctly deeply' ,  ( )  =>  { 
918+ 		scratch . innerHTML  = 
919+ 			'<!--$s--><!--$s--><!--/$s--><!--/$s--><div>Hello world</div>' ; 
920+ 		clearLog ( ) ; 
921+ 
922+ 		const  [ Lazy ,  resolve ]  =  createLazy ( ) ; 
923+ 		const  [ Lazy2 ,  resolve2 ]  =  createLazy ( ) ; 
924+ 		hydrate ( 
925+ 			< > 
926+ 				< Suspense > 
927+ 					< Lazy > 
928+ 						< Suspense > 
929+ 							< Lazy2  /> 
930+ 						</ Suspense > 
931+ 					</ Lazy > 
932+ 				</ Suspense > 
933+ 				< div > Hello world</ div > 
934+ 			</ > , 
935+ 			scratch 
936+ 		) ; 
937+ 		rerender ( ) ;  // Flush rerender queue to mimic what preact will really do 
938+ 		expect ( scratch . innerHTML ) . to . equal ( 
939+ 			'<!--$s--><!--$s--><!--/$s--><!--/$s--><div>Hello world</div>' 
940+ 		) ; 
941+ 		expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
942+ 		clearLog ( ) ; 
943+ 
944+ 		return  resolve ( p  =>  p . children ) . then ( ( )  =>  { 
945+ 			rerender ( ) ; 
946+ 			expect ( scratch . innerHTML ) . to . equal ( 
947+ 				'<!--$s--><!--$s--><!--/$s--><!--/$s--><div>Hello world</div>' 
948+ 			) ; 
949+ 			expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
950+ 
951+ 			clearLog ( ) ; 
952+ 			return  resolve2 ( ( )  =>  null ) . then ( ( )  =>  { 
953+ 				rerender ( ) ; 
954+ 				expect ( scratch . innerHTML ) . to . equal ( 
955+ 					'<!--$s--><!--$s--><!--/$s--><!--/$s--><div>Hello world</div>' 
956+ 				) ; 
957+ 				expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
958+ 
959+ 				clearLog ( ) ; 
960+ 			} ) ; 
961+ 		} ) ; 
962+ 	} ) ; 
963+ 
964+ 	it ( 'Should hydrate a fragment with multiple children correctly deeply' ,  ( )  =>  { 
965+ 		scratch . innerHTML  = 
966+ 			'<!--$s--><!--$s--><p>I am</p><span>Fragment</span><!--/$s--><!--/$s--><div>Hello world</div>' ; 
967+ 		clearLog ( ) ; 
968+ 
969+ 		const  [ Lazy ,  resolve ]  =  createLazy ( ) ; 
970+ 		const  [ Lazy2 ,  resolve2 ]  =  createLazy ( ) ; 
971+ 		hydrate ( 
972+ 			< > 
973+ 				< Suspense > 
974+ 					< Lazy > 
975+ 						< Suspense > 
976+ 							< Lazy2  /> 
977+ 						</ Suspense > 
978+ 					</ Lazy > 
979+ 				</ Suspense > 
980+ 				< div > Hello world</ div > 
981+ 			</ > , 
982+ 			scratch 
983+ 		) ; 
984+ 		rerender ( ) ;  // Flush rerender queue to mimic what preact will really do 
985+ 		expect ( scratch . innerHTML ) . to . equal ( 
986+ 			'<!--$s--><!--$s--><p>I am</p><span>Fragment</span><!--/$s--><!--/$s--><div>Hello world</div>' 
987+ 		) ; 
988+ 		expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
989+ 		clearLog ( ) ; 
990+ 
991+ 		return  resolve ( p  =>  p . children ) . then ( ( )  =>  { 
992+ 			rerender ( ) ; 
993+ 			expect ( scratch . innerHTML ) . to . equal ( 
994+ 				'<!--$s--><!--$s--><p>I am</p><span>Fragment</span><!--/$s--><!--/$s--><div>Hello world</div>' 
995+ 			) ; 
996+ 			expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
997+ 
998+ 			clearLog ( ) ; 
999+ 			return  resolve2 ( ( )  =>  ( 
1000+ 				< > 
1001+ 					< p > I am</ p > 
1002+ 					< span > Fragment</ span > 
1003+ 				</ > 
1004+ 			) ) . then ( ( )  =>  { 
1005+ 				rerender ( ) ; 
1006+ 				expect ( scratch . innerHTML ) . to . equal ( 
1007+ 					'<!--$s--><!--$s--><p>I am</p><span>Fragment</span><!--/$s--><!--/$s--><div>Hello world</div>' 
1008+ 				) ; 
1009+ 				expect ( getLog ( ) ) . to . deep . equal ( [ ] ) ; 
1010+ 
1011+ 				clearLog ( ) ; 
1012+ 			} ) ; 
1013+ 		} ) ; 
1014+ 	} ) ; 
8421015} ) ; 
0 commit comments