Skip to content

Commit f036950

Browse files
committed
Add unit test
1 parent d57c1e8 commit f036950

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

tests/DOMAPI/AddEventListener__test.js

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
open WebAPI
2+
open WebAPI.Global
3+
4+
let button = document->Document.querySelector("button")->Null.toOption
5+
let h2 = document->Document.querySelector("h2")->Null.toOption
6+
7+
switch (button, h2) {
8+
| (Some(button), Some(h2)) =>
9+
button->Element.addEventListener(EventAPI.Click, (e: UIEventsAPI.mouseEvent) => {
10+
Console.log(`Button clicked, ${Int.toString(e.button)}`)
11+
switch h2.textContent {
12+
| Null => h2.textContent = Value("1")
13+
| Value(text) =>
14+
switch Int.fromString(text) {
15+
| None => h2.textContent = Value("1")
16+
| Some(number) => h2.textContent = Value(Int.toString(number + 1))
17+
}
18+
}
19+
})
20+
| _ => Console.log("Stuff not found")
21+
}

0 commit comments

Comments
 (0)