Skip to content

Commit e45d37f

Browse files
authored
Assert on queriedButton not button in the test (#6)
The current test was meaningless as we didn't assert on the text content of `queriedButton`. I've also removed `addEventListener` because it doesn't actually work. The `button` instance is already deallocated by the time that test has finished, so the closure passed to `addEventListener` is released too. We need to find a way to run async tests like this, and I have a few thoughts, but this still needs to be explored.
1 parent e4b50a4 commit e45d37f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Diff for: Tests/DOMKitTests/DOMKitTests.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@ final class DOMKitTests: XCTestCase {
66
let document = globalThis.document
77
let button = document.createElement(localName: "button")
88
button.textContent = "Hello, world!"
9-
button.addEventListener(type: "click") { event in
10-
(event.target as? HTMLElement)?.textContent = "Clicked!"
11-
}
129
_ = document.querySelector(selectors: "body")?.appendChild(node: button)
1310

1411
let queriedButton = document.querySelector(selectors: "body button")
15-
XCTAssertEqual(button.textContent, "Hello, world!")
12+
XCTAssertEqual(queriedButton?.textContent, "Hello, world!")
1613
}
1714
}

0 commit comments

Comments
 (0)