@@ -63,7 +63,8 @@ describe('Binding: Foreach', function () {
6363 testNode . innerHTML = "<div data-bind='foreach: someItems'><span data-bind='text: childProp'></span></div>"
6464 const someItems = [ { childProp : 'first child' } , { childProp : 'second child' } ]
6565 applyBindings ( { someItems : someItems } , testNode )
66- expectContainHtml ( testNode . childNodes [ 0 ] ,
66+ expectContainHtml (
67+ testNode . childNodes [ 0 ] ,
6768 '<span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span>'
6869 )
6970 } )
@@ -99,7 +100,8 @@ describe('Binding: Foreach', function () {
99100 testNode . innerHTML = "<div data-bind='foreach: someItems'><span data-bind='text: $data'></span></div>"
100101 const someItems = [ 'alpha' , 'beta' ]
101102 applyBindings ( { someItems : someItems } , testNode )
102- expectContainHtml ( testNode . childNodes [ 0 ] ,
103+ expectContainHtml (
104+ testNode . childNodes [ 0 ] ,
103105 '<span data-bind="text: $data">alpha</span><span data-bind="text: $data">beta</span>'
104106 )
105107 } )
@@ -108,43 +110,50 @@ describe('Binding: Foreach', function () {
108110 testNode . innerHTML = "<div data-bind='foreach: someItems'><span data-bind='text: childProp'></span></div>"
109111 const someItems = observableArray ( [ { childProp : 'first child' } , { childProp : 'second child' } ] )
110112 applyBindings ( { someItems : someItems } , testNode )
111- expectContainHtml ( testNode . childNodes [ 0 ] ,
113+ expectContainHtml (
114+ testNode . childNodes [ 0 ] ,
112115 '<span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span>'
113116 )
114117
115118 // Add items at the beginning...
116119 someItems . unshift ( { childProp : 'zeroth child' } )
117- expectContainHtml ( testNode . childNodes [ 0 ] ,
120+ expectContainHtml (
121+ testNode . childNodes [ 0 ] ,
118122 '<span data-bind="text: childprop">zeroth child</span><span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span>'
119123 )
120124
121125 // ... middle
122126 someItems . splice ( 2 , 0 , { childProp : 'middle child' } )
123- expectContainHtml ( testNode . childNodes [ 0 ] ,
127+ expectContainHtml (
128+ testNode . childNodes [ 0 ] ,
124129 '<span data-bind="text: childprop">zeroth child</span><span data-bind="text: childprop">first child</span><span data-bind="text: childprop">middle child</span><span data-bind="text: childprop">second child</span>'
125130 )
126131
127132 // ... and end
128133 someItems . push ( { childProp : 'last child' } )
129- expectContainHtml ( testNode . childNodes [ 0 ] ,
134+ expectContainHtml (
135+ testNode . childNodes [ 0 ] ,
130136 '<span data-bind="text: childprop">zeroth child</span><span data-bind="text: childprop">first child</span><span data-bind="text: childprop">middle child</span><span data-bind="text: childprop">second child</span><span data-bind="text: childprop">last child</span>'
131137 )
132138
133139 // Also remove from beginning...
134140 someItems . shift ( )
135- expectContainHtml ( testNode . childNodes [ 0 ] ,
141+ expectContainHtml (
142+ testNode . childNodes [ 0 ] ,
136143 '<span data-bind="text: childprop">first child</span><span data-bind="text: childprop">middle child</span><span data-bind="text: childprop">second child</span><span data-bind="text: childprop">last child</span>'
137144 )
138145
139146 // ... and middle
140147 someItems . splice ( 1 , 1 )
141- expectContainHtml ( testNode . childNodes [ 0 ] ,
148+ expectContainHtml (
149+ testNode . childNodes [ 0 ] ,
142150 '<span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span><span data-bind="text: childprop">last child</span>'
143151 )
144152
145153 // ... and end
146154 someItems . pop ( )
147- expectContainHtml ( testNode . childNodes [ 0 ] ,
155+ expectContainHtml (
156+ testNode . childNodes [ 0 ] ,
148157 '<span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span>'
149158 )
150159
@@ -160,7 +169,8 @@ describe('Binding: Foreach', function () {
160169 testNode . innerHTML = "<div data-bind='foreach: someitems'>a<!-- ko if:true -->b<!-- /ko --></div>"
161170 const someitems = observableArray ( [ 1 , 2 ] )
162171 applyBindings ( { someitems : someitems } , testNode )
163- expectContainHtml ( testNode ,
172+ expectContainHtml (
173+ testNode ,
164174 '<div data-bind="foreach: someitems">a<!-- ko if:true -->b<!-- /ko -->a<!-- ko if:true -->b<!-- /ko --></div>'
165175 )
166176
@@ -205,7 +215,8 @@ describe('Binding: Foreach', function () {
205215 "<div data-bind='foreach: { data: someItems, includeDestroyed: true }'><span data-bind='text: childProp'></span></div>"
206216 const someItems = observableArray ( [ { childProp : 'first child' } , { childProp : 'second child' , _destroy : true } ] )
207217 applyBindings ( { someItems : someItems } , testNode )
208- expectContainHtml ( testNode . childNodes [ 0 ] ,
218+ expectContainHtml (
219+ testNode . childNodes [ 0 ] ,
209220 '<span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span>'
210221 )
211222 } )
@@ -237,13 +248,15 @@ describe('Binding: Foreach', function () {
237248
238249 // Try adding
239250 someItems . push ( 'added child' )
240- expectContainHtml ( divNode ,
251+ expectContainHtml (
252+ divNode ,
241253 '<span data-bind="text: $data">first child</span><span data-bind="text: $data">added child</span>'
242254 )
243255 expect ( afterAddCallbackData . length ) . to . equal ( 1 )
244256 expect ( afterAddCallbackData [ 0 ] . elem ) . to . equal ( divNode . childNodes [ 1 ] )
245257 expect ( afterAddCallbackData [ 0 ] . value ) . to . equal ( 'added child' )
246- expectContainHtml ( afterAddCallbackData [ 0 ] . currentParentClone ,
258+ expectContainHtml (
259+ afterAddCallbackData [ 0 ] . currentParentClone ,
247260 '<span data-bind="text: $data">first child</span><span data-bind="text: $data">added child</span>'
248261 )
249262
@@ -253,10 +266,12 @@ describe('Binding: Foreach', function () {
253266 expectContainText ( beforeRemoveCallbackData [ 0 ] . elem , 'first child' )
254267 expect ( beforeRemoveCallbackData [ 0 ] . value ) . to . equal ( 'first child' )
255268 // Note that when using "beforeRemove", we *don't* remove the node from the doc - it's up to the beforeRemove callback to do it. So, check it's still there.
256- expectContainHtml ( beforeRemoveCallbackData [ 0 ] . currentParentClone ,
269+ expectContainHtml (
270+ beforeRemoveCallbackData [ 0 ] . currentParentClone ,
257271 '<span data-bind="text: $data">first child</span><span data-bind="text: $data">added child</span>'
258272 )
259- expectContainHtml ( divNode ,
273+ expectContainHtml (
274+ divNode ,
260275 '<span data-bind="text: $data">first child</span><span data-bind="text: $data">added child</span>'
261276 )
262277
@@ -267,10 +282,12 @@ describe('Binding: Foreach', function () {
267282 expectContainText ( beforeRemoveCallbackData [ 0 ] . elem , 'added child' )
268283 expect ( beforeRemoveCallbackData [ 0 ] . value ) . to . equal ( 'added child' )
269284 // Neither item has yet been removed and both are still in their original locations
270- expectContainHtml ( beforeRemoveCallbackData [ 0 ] . currentParentClone ,
285+ expectContainHtml (
286+ beforeRemoveCallbackData [ 0 ] . currentParentClone ,
271287 '<span data-bind="text: $data">first child</span><span data-bind="text: $data">added child</span>'
272288 )
273- expectContainHtml ( divNode ,
289+ expectContainHtml (
290+ divNode ,
274291 '<span data-bind="text: $data">first child</span><span data-bind="text: $data">added child</span>'
275292 )
276293
@@ -543,10 +560,12 @@ describe('Binding: Foreach', function () {
543560 applyBindings ( viewModel , testNode )
544561
545562 // Verify we can access binding contexts during binding
546- expectContainText ( testNode . childNodes [ 0 ] . childNodes [ 0 ] ,
563+ expectContainText (
564+ testNode . childNodes [ 0 ] . childNodes [ 0 ] ,
547565 '(Val: A1, Parents: 2, Rootval: ROOTVAL)(Val: A2, Parents: 2, Rootval: ROOTVAL)(Val: A3, Parents: 2, Rootval: ROOTVAL)'
548566 )
549- expectContainText ( testNode . childNodes [ 0 ] . childNodes [ 1 ] ,
567+ expectContainText (
568+ testNode . childNodes [ 0 ] . childNodes [ 1 ] ,
550569 '(Val: B1, Parents: 2, Rootval: ROOTVAL)(Val: B2, Parents: 2, Rootval: ROOTVAL)'
551570 )
552571
@@ -563,7 +582,8 @@ describe('Binding: Foreach', function () {
563582 testNode . innerHTML = "hi <!-- ko foreach: someitems --><span data-bind='text: childprop'></span><!-- /ko -->"
564583 const someitems = [ { childprop : 'first child' } , { childprop : 'second child' } ]
565584 applyBindings ( { someitems : someitems } , testNode )
566- expectContainHtml ( testNode ,
585+ expectContainHtml (
586+ testNode ,
567587 'hi <!-- ko foreach: someitems --><span data-bind="text: childprop">first child</span><span data-bind="text: childprop">second child</span><!-- /ko -->'
568588 )
569589
@@ -595,7 +615,8 @@ describe('Binding: Foreach', function () {
595615 applyBindings ( viewModel , testNode )
596616
597617 // Verify we can access binding contexts during binding
598- expectContainText ( testNode ,
618+ expectContainText (
619+ testNode ,
599620 '(Val: A1, Parents: 2, Rootval: ROOTVAL)(Val: A2, Parents: 2, Rootval: ROOTVAL)(Val: A3, Parents: 2, Rootval: ROOTVAL)(Val: B1, Parents: 2, Rootval: ROOTVAL)(Val: B2, Parents: 2, Rootval: ROOTVAL)'
600621 )
601622
@@ -627,7 +648,8 @@ describe('Binding: Foreach', function () {
627648 }
628649 applyBindings ( viewModel , testNode )
629650
630- expectContainHtml ( testNode ,
651+ expectContainHtml (
652+ testNode ,
631653 '<ul>'
632654 + '<!--ko foreach: items-->'
633655 + '<li>'
@@ -665,17 +687,20 @@ describe('Binding: Foreach', function () {
665687 // Any of the following results are acceptable.
666688 if ( ! match ) {
667689 // Opera 11.5 doesn't add any closing </li> tags
668- expectContainHtml ( testNode ,
690+ expectContainHtml (
691+ testNode ,
669692 '<ul><li>header item<!-- ko foreach: someitems --><li data-bind="text: $data">alpha<li data-bind="text: $data">beta<!-- /ko --></ul>'
670693 )
671694 } else if ( match . length == 3 ) {
672695 // Modern browsers implicitly re-add the closing </li> tags
673- expectContainHtml ( testNode ,
696+ expectContainHtml (
697+ testNode ,
674698 '<ul><li>header item</li><!-- ko foreach: someitems --><li data-bind="text: $data">alpha</li><li data-bind="text: $data">beta</li><!-- /ko --></ul>'
675699 )
676700 } else {
677701 // ... but IE < 8 doesn't add ones that immediately precede a <li>
678- expectContainHtml ( testNode ,
702+ expectContainHtml (
703+ testNode ,
679704 '<ul><li>header item</li><!-- ko foreach: someitems --><li data-bind="text: $data">alpha<li data-bind="text: $data">beta</li><!-- /ko --></ul>'
680705 )
681706 }
@@ -717,7 +742,8 @@ describe('Binding: Foreach', function () {
717742 "<div data-bind='foreach: { data: someItems, as: \"item\" }'><span data-bind='text: item'></span></div>"
718743 const someItems = [ 'alpha' , 'beta' ]
719744 applyBindings ( { someItems : someItems } , testNode )
720- expectContainHtml ( testNode . childNodes [ 0 ] ,
745+ expectContainHtml (
746+ testNode . childNodes [ 0 ] ,
721747 '<span data-bind="text: item">alpha</span><span data-bind="text: item">beta</span>'
722748 )
723749 } )
@@ -773,7 +799,8 @@ describe('Binding: Foreach', function () {
773799 setHtml ( testNode , "<div data-bind='foreach:someitems'><section data-bind='text: $data'></section></div>" )
774800 const viewModel = { someitems : [ 'Alpha' , 'Beta' ] }
775801 applyBindings ( viewModel , testNode )
776- expectContainHtml ( testNode ,
802+ expectContainHtml (
803+ testNode ,
777804 '<div data-bind="foreach:someitems"><section data-bind="text: $data">alpha</section><section data-bind="text: $data">beta</section></div>'
778805 )
779806 } )
@@ -786,7 +813,8 @@ describe('Binding: Foreach', function () {
786813 )
787814 const viewModel = { someitems : [ 'Alpha' , 'Beta' ] }
788815 applyBindings ( viewModel , testNode )
789- expectContainHtml ( testNode ,
816+ expectContainHtml (
817+ testNode ,
790818 'xxx<!-- ko foreach:someitems --><div><section data-bind="text: $data">alpha</section></div><div><section data-bind="text: $data">beta</section></div><!-- /ko -->'
791819 )
792820 } )
0 commit comments