@@ -53,39 +53,37 @@ describe('nanoviews', () => {
5353 } )
5454
5555 it ( 'should render with initial footer' , ( ) => {
56- it ( 'should render without initial value' , ( ) => {
57- let addBlock : GetChildHook
58- let setFooterBlock : GetChildHook
59- let resetBlocks : GetChildHook
60- const list = createAsyncList ( 'Footer' , ( a , s , r ) => {
61- addBlock = a
62- setFooterBlock = s
63- resetBlocks = r
64- } )
65- const { container } = render ( list )
56+ let addBlock : GetChildHook
57+ let setFooterBlock : GetChildHook
58+ let resetBlocks : GetChildHook
59+ const list = createAsyncList ( 'Footer' , ( a , s , r ) => {
60+ addBlock = a
61+ setFooterBlock = s
62+ resetBlocks = r
63+ } )
64+ const { container } = render ( list )
6665
67- expect ( container . innerHTML ) . toBe ( '<div>Footer</div>' )
66+ expect ( container . innerHTML ) . toBe ( '<div>Footer</div>' )
6867
69- addBlock ! ( ( ) => createElement ( 'div' ) ( 'A' ) )
68+ addBlock ! ( ( ) => createElement ( 'div' ) ( 'A' ) )
7069
71- expect ( container . innerHTML ) . toBe ( '<div><div>A</div>Footer</div>' )
70+ expect ( container . innerHTML ) . toBe ( '<div><div>A</div>Footer</div>' )
7271
73- setFooterBlock ! ( ( ) => 'retooF' )
72+ setFooterBlock ! ( ( ) => 'retooF' )
7473
75- expect ( container . innerHTML ) . toBe ( '<div><div>A</div>retooF</div>' )
74+ expect ( container . innerHTML ) . toBe ( '<div><div>A</div>retooF</div>' )
7675
77- addBlock ! ( ( ) => createElement ( 'div' ) ( 'B' ) )
76+ addBlock ! ( ( ) => createElement ( 'div' ) ( 'B' ) )
7877
79- expect ( container . innerHTML ) . toBe ( '<div><div>A</div><div>B</div>retooF</div>' )
78+ expect ( container . innerHTML ) . toBe ( '<div><div>A</div><div>B</div>retooF</div>' )
8079
81- resetBlocks ! ( )
80+ resetBlocks ! ( )
8281
83- expect ( container . innerHTML ) . toBe ( '<div></div>' )
82+ expect ( container . innerHTML ) . toBe ( '<div></div>' )
8483
85- resetBlocks ! ( ( ) => 'Footer' )
84+ resetBlocks ! ( ( ) => 'Footer' )
8685
87- expect ( container . innerHTML ) . toBe ( '<div>Footer</div>' )
88- } )
86+ expect ( container . innerHTML ) . toBe ( '<div>Footer</div>' )
8987 } )
9088
9189 it ( 'should call destroy function' , ( ) => {
@@ -131,6 +129,40 @@ describe('nanoviews', () => {
131129
132130 expect ( container . innerHTML ) . toBe ( '<div><div>(C) dark</div></div>' )
133131 } )
132+
133+ it ( 'should render in reversed order' , ( ) => {
134+ let addBlock : GetChildHook
135+ let setFooterBlock : GetChildHook
136+ let resetBlocks : GetChildHook
137+ const list = createAsyncList ( 'Footer' , ( a , s , r ) => {
138+ addBlock = a
139+ setFooterBlock = s
140+ resetBlocks = r
141+ } , true )
142+ const { container } = render ( list )
143+
144+ expect ( container . innerHTML ) . toBe ( '<div>Footer</div>' )
145+
146+ addBlock ! ( ( ) => createElement ( 'div' ) ( 'A' ) )
147+
148+ expect ( container . innerHTML ) . toBe ( '<div>Footer<div>A</div></div>' )
149+
150+ setFooterBlock ! ( ( ) => 'retooF' )
151+
152+ expect ( container . innerHTML ) . toBe ( '<div>retooF<div>A</div></div>' )
153+
154+ addBlock ! ( ( ) => createElement ( 'div' ) ( 'B' ) )
155+
156+ expect ( container . innerHTML ) . toBe ( '<div>retooF<div>B</div><div>A</div></div>' )
157+
158+ resetBlocks ! ( )
159+
160+ expect ( container . innerHTML ) . toBe ( '<div></div>' )
161+
162+ resetBlocks ! ( ( ) => 'Footer' )
163+
164+ expect ( container . innerHTML ) . toBe ( '<div>Footer</div>' )
165+ } )
134166 } )
135167 } )
136168 } )
0 commit comments