forked from hyoo-ru/mam_mol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.test.ts
42 lines (29 loc) · 943 Bytes
/
button.test.ts
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
namespace $.$$ {
$mol_test({
'handle clicks by default'($) {
let clicked = false
const clicker = $mol_button.make({
$,
event_click : ( event : MouseEvent )=> { clicked = true } ,
})
const element = clicker.dom_tree() as HTMLButtonElement
const event = $mol_dom_context.document.createEvent( 'mouseevent' )
event.initEvent( 'click' , true , true )
element.dispatchEvent( event )
$mol_assert_ok( clicked )
} ,
'no handle clicks if disabled'($) {
let clicked = false
const clicker = $mol_button.make({
$,
event_click : ( event : MouseEvent )=> { clicked = true } ,
enabled : ()=> false ,
})
const element = clicker.dom_tree() as HTMLButtonElement
const event = $mol_dom_context.document.createEvent( 'mouseevent' )
event.initEvent( 'click' , true , true )
element.dispatchEvent( event )
$mol_assert_not( clicked )
} ,
})
}