-
Notifications
You must be signed in to change notification settings - Fork 443
Expand file tree
/
Copy pathmemory_tests.ts
More file actions
40 lines (30 loc) · 1.4 KB
/
memory_tests.ts
File metadata and controls
40 lines (30 loc) · 1.4 KB
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
import { ControllerTestCase } from "../../cases/controller_test_case"
export default class MemoryTests extends ControllerTestCase() {
controllerElement!: Element
async setup() {
this.controllerElement = this.controller.element
}
fixtureHTML = `
<div data-controller="${this.identifier}">
<button id="button1" data-action="${this.identifier}#doLog">Log</button>
<button id="button2" data-action="${this.identifier}#doAlert ${this.identifier}#log2">Alert</button>
</div>
`
async "test removing a controller clears dangling eventListeners"() {
this.assert.equal(this.application.dispatcher.eventListeners.length, 2)
await this.fixtureElement.removeChild(this.controllerElement)
this.assert.equal(this.application.dispatcher.eventListeners.length, 0)
}
async "test removing a button clears dangling eventListeners"() {
this.assert.equal(this.application.dispatcher.eventListeners.length, 2)
const button = this.findElement("#button1")
await this.remove(button)
this.assert.equal(this.application.dispatcher.eventListeners.length, 1)
}
async "test removing a button clears dangling eventListeners with multiple actions"() {
this.assert.equal(this.application.dispatcher.eventListeners.length, 2)
const button = this.findElement("#button2")
await this.remove(button)
this.assert.equal(this.application.dispatcher.eventListeners.length, 1)
}
}