Skip to content

Commit 4d4d88d

Browse files
committed
adding tests back in and tidying up
1 parent b3760db commit 4d4d88d

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

src/core/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class Controller<ElementType extends Element = Element> {
101101
prefix = this.identifier,
102102
bubbles = true,
103103
cancelable = true,
104-
}: DispatchOptions = {},
104+
}: DispatchOptions = {}
105105
) {
106106
const type = prefix ? `${prefix}:${eventName}` : eventName
107107
const event = new CustomEvent(type, { detail, bubbles, cancelable })

src/tests/modules/core/find_element_test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,28 @@ export default class FindElementTests extends ControllerTestCase(ClassController
1111
<div id="inside-id" class="busy"></div>
1212
</div>
1313
<div id="outside-id" class="busy"></div>
14+
15+
"test findElement finds element by id inside scope"() {
16+
const result = this.controller.findElement("inside-id")
17+
this.assert.equal(result?.id, "inside-id")
18+
}
19+
20+
"test findElement does not find element by id outside scope"() {
21+
const result = this.controller.findElement("outside-id")
22+
this.assert.equal(result, undefined)
23+
}
24+
25+
"test findElement finds element by defined class"() {
26+
const result = this.controller.findElement(this.controller.loadingClass)
27+
this.assert.ok(result instanceof Element)
28+
this.assert.ok(result?.classList.contains("busy"))
29+
}
30+
31+
"test findAllElements returns multiple matches for defined class"() {
32+
const results = this.controller.findAllElements(this.controller.loadingClass)
33+
this.assert.ok(Array.isArray(results))
34+
this.assert.equal(results.length, 1)
35+
this.assert.ok(results[0].classList.contains("busy"))
36+
}
1437
`
1538
}

0 commit comments

Comments
 (0)