Skip to content

Commit 21e37a0

Browse files
committed
+ run prettier
1 parent a79638a commit 21e37a0

File tree

13 files changed

+177
-100
lines changed

13 files changed

+177
-100
lines changed

packages/binding.component/spec/componentBindingBehaviors.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ import components from '@tko/utils.component'
2626

2727
import { expect } from 'chai'
2828
import sinon from 'sinon'
29-
import { expectContainHtml, expectContainText, prepareTestNode, restoreAfter, useMockForTasks } from '../../utils/helpers/mocha-test-helpers'
29+
import {
30+
expectContainHtml,
31+
expectContainText,
32+
prepareTestNode,
33+
restoreAfter,
34+
useMockForTasks
35+
} from '../../utils/helpers/mocha-test-helpers'
3036

3137
describe('Components: Component binding', function () {
3238
let testComponentName = 'test-component',
@@ -100,9 +106,7 @@ describe('Components: Component binding', function () {
100106
testNode.innerHTML = '<div data-bind="if: true, component: $data"></div>'
101107
expect(function () {
102108
applyBindings(testComponentName, testNode)
103-
}).to.throw(
104-
'Multiple bindings (if and component) are trying to control descendant bindings of the same element.'
105-
)
109+
}).to.throw('Multiple bindings (if and component) are trying to control descendant bindings of the same element.')
106110

107111
// Even though applyBindings threw an exception, the component still gets bound (asynchronously)
108112
clock.tick(1)
@@ -241,7 +245,8 @@ describe('Components: Component binding', function () {
241245
applyBindings(outerViewModel, testNode)
242246
clock.tick(1)
243247

244-
expectContainHtml(testNode.children[0],
248+
expectContainHtml(
249+
testNode.children[0],
245250
'start<span data-bind="template: { nodes: $componenttemplatenodes }"><em>original</em> child nodes</span>end'
246251
)
247252
})
@@ -274,7 +279,8 @@ describe('Components: Component binding', function () {
274279
applyBindings(outerViewModel, testNode)
275280
clock.tick(1)
276281

277-
expectContainText(testNode.children[0],
282+
expectContainText(
283+
testNode.children[0],
278284
'In child context 123, inside component with property 456. Now in sub-component with property 789.',
279285
/* ignoreSpaces */ true
280286
) // Ignore spaces because old-IE is inconsistent
@@ -1383,7 +1389,9 @@ describe('Components: Component binding', function () {
13831389
)
13841390

13851391
arr([])
1386-
expect(testNode.innerHTML).to.deep.equal(`<test-component><div><!--ko slot: "X"--><!--/ko--></div></test-component>`)
1392+
expect(testNode.innerHTML).to.deep.equal(
1393+
`<test-component><div><!--ko slot: "X"--><!--/ko--></div></test-component>`
1394+
)
13871395
})
13881396

13891397
it('respects observable array changes with JSX', function () {

packages/binding.core/spec/optionsBehaviors.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,11 @@ describe('Binding: Options', function () {
234234
})
235235
applyBindings({ myValues: myObservable }, testNode)
236236
expect(changeHandlerFireCount).to.equal(0)
237-
238237
;(testNode.childNodes[0] as HTMLSelectElement).options[0].selected = true
239238
expectHaveSelectedValues(testNode.childNodes[0], ['A'])
240239
myObservable(['B', 'C', 'A'])
241240
expectHaveSelectedValues(testNode.childNodes[0], ['A'])
242241
expect(changeHandlerFireCount).to.equal(0)
243-
244242
;(testNode.childNodes[0] as HTMLSelectElement).options[0].selected = true
245243
expectHaveSelectedValues(testNode.childNodes[0], ['B', 'A'])
246244
myObservable(['C', 'A'])
@@ -319,7 +317,7 @@ describe('Binding: Options', function () {
319317
{ name: observable('Bert'), id: 'B' }
320318
]
321319
testNode.innerHTML =
322-
'<select data-bind="options: people, optionsText: \'name\', optionsValue: \'id\', optionsCaption: \'-\'"></select>'
320+
"<select data-bind=\"options: people, optionsText: 'name', optionsValue: 'id', optionsCaption: '-'\"></select>"
323321
applyBindings({ people: people }, testNode)
324322
;(testNode.childNodes[0] as HTMLSelectElement).options[2].selected = true
325323

packages/binding.core/spec/textBehaviors.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { options } from '@tko/utils'
1212
import * as coreBindings from '../dist'
1313

1414
import { Provider } from '@tko/provider'
15-
import { expectContainHtml, expectContainText, prepareTestNode, restoreAfter } from '../../utils/helpers/mocha-test-helpers'
15+
import {
16+
expectContainHtml,
17+
expectContainText,
18+
prepareTestNode,
19+
restoreAfter
20+
} from '../../utils/helpers/mocha-test-helpers'
1621

1722
describe('Binding: Text', function () {
1823
let bindingHandlers

packages/binding.core/spec/usingBehaviors.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,7 @@ describe('Binding: Using', function () {
169169
expectContainHtml(container, '<div data-bind="foreach: childprop"></div>')
170170

171171
childprop.push('me')
172-
expectContainHtml(
173-
container,
174-
'<div data-bind="foreach: childprop"><span data-bind=\"text: $data\">me</span></div>'
175-
)
172+
expectContainHtml(container, '<div data-bind="foreach: childprop"><span data-bind=\"text: $data\">me</span></div>')
176173

177174
childprop.push('me2')
178175
expectContainHtml(
@@ -201,7 +198,10 @@ describe('Binding: Using', function () {
201198
expectContainHtml(container, 'text<!-- ko foreach: childprop --><!-- /ko -->')
202199

203200
childprop.push('me')
204-
expectContainHtml(container, 'text<!-- ko foreach: childprop --><span data-bind="text: $data">me</span><!-- /ko -->')
201+
expectContainHtml(
202+
container,
203+
'text<!-- ko foreach: childprop --><span data-bind="text: $data">me</span><!-- /ko -->'
204+
)
205205

206206
childprop.push('me2')
207207
expectContainHtml(

packages/binding.if/spec/withBehaviors.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ describe('Binding: With', function () {
218218
expect((testNode.childNodes[0].childNodes[0] as HTMLInputElement).value).to.equal('Hello')
219219

220220
expect(dataFor(testNode.childNodes[0].childNodes[0])).to.equal(dataFor(testNode))
221-
222221
;(testNode.childNodes[0].childNodes[0] as HTMLInputElement).value = 'Goodbye'
223222
triggerEvent(testNode.children[0].children[0], 'change')
224223
expect(someItem()).to.equal('Goodbye')
@@ -320,7 +319,6 @@ describe('Binding: With', function () {
320319
expect(item.getSubscriptionsCount('change')).to.equal(3)
321320
expectValues(testNode.childNodes[0], ['one'])
322321
expectContainText(testNode.childNodes[0], 'one')
323-
324322
;(testNode.childNodes[0].childNodes[0] as HTMLInputElement).value = 'two'
325323
triggerEvent(testNode.children[0].children[0], 'change')
326324
expect(item()).to.equal('two')

packages/binding.template/spec/foreachBehaviors.ts

Lines changed: 56 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)