Skip to content
This repository was archived by the owner on Sep 22, 2022. It is now read-only.

Commit bbaf00e

Browse files
committed
Test in a nested environment and assert event count
1 parent 4c7c4f2 commit bbaf00e

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

test/test.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,25 @@ describe('details-dialog-element', function() {
2222
beforeEach(function() {
2323
const container = document.createElement('div')
2424
container.innerHTML = `
25-
<details>
26-
<summary>Click</summary>
27-
<details-dialog>
28-
<p>Hello</p>
29-
<button data-button>Button</button>
30-
<button hidden>hidden</button>
31-
<div hidden><button>hidden</button></div>
32-
<details><button>Button in closed details</button></details>
33-
<button ${CLOSE_ATTR}>Goodbye</button>
34-
</details-dialog>
25+
<details open>
26+
<details id="details">
27+
<summary id="summary">Click</summary>
28+
<details-dialog>
29+
<p>Hello</p>
30+
<button data-button>Button</button>
31+
<button hidden>hidden</button>
32+
<div hidden><button>hidden</button></div>
33+
<details><button>Button in closed details</button></details>
34+
<button ${CLOSE_ATTR}>Goodbye</button>
35+
</details-dialog>
36+
</details>
3537
</details>
3638
`
3739
document.body.append(container)
3840

39-
details = document.querySelector('details')
41+
details = document.querySelector('#details')
4042
dialog = details.querySelector('details-dialog')
41-
summary = details.querySelector('summary')
43+
summary = details.querySelector('#summary')
4244
close = dialog.querySelector(CLOSE_SELECTOR)
4345
})
4446

@@ -135,6 +137,11 @@ describe('details-dialog-element', function() {
135137
allowCloseToHappen = true
136138
close.click()
137139
assert(!details.open)
140+
assert.equal(closeRequestCount, 5)
141+
142+
summary.click()
143+
assert(details.open)
144+
assert.equal(closeRequestCount, 5)
138145
})
139146

140147
describe('when no summary element is present', function() {

0 commit comments

Comments
 (0)