forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_config.js
43 lines (35 loc) · 1.26 KB
/
_config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export default {
data: {
items: [
{ description: 'one', completed: true },
{ description: 'two', completed: false },
{ description: 'three', completed: false }
]
},
html: `
<div><input type="checkbox"><p>one</p></div><div><input type="checkbox"><p>two</p></div><div><input type="checkbox"><p>three</p></div>
<p>1 completed</p>
`,
test ( assert, component, target, window ) {
const inputs = [ ...target.querySelectorAll( 'input' ) ];
assert.ok( inputs[0].checked );
assert.ok( !inputs[1].checked );
assert.ok( !inputs[2].checked );
const event = new window.Event( 'change' );
inputs[1].checked = true;
inputs[1].dispatchEvent( event );
assert.equal( component.get( 'numCompleted' ), 2 );
assert.htmlEqual( target.innerHTML, `
<div><input type="checkbox"><p>one</p></div><div><input type="checkbox"><p>two</p></div><div><input type="checkbox"><p>three</p></div>
<p>2 completed</p>
` );
const items = component.get( 'items' );
items[2].completed = true;
component.set({ items });
assert.ok( inputs[2].checked );
assert.htmlEqual( target.innerHTML, `
<div><input type="checkbox"><p>one</p></div><div><input type="checkbox"><p>two</p></div><div><input type="checkbox"><p>three</p></div>
<p>3 completed</p>
` );
}
};