gadjo/tests/js/foldable-sections.test.js

20 lines
538 B
JavaScript

const assert = require('assert')
const { loadDom } = require('./test-utils')
test('test foldable sections', async () => {
const { window } = await loadDom(`
<div class="section foldable">
<h2>Section Title</h2>
</div>
`)
const foldableSection = window.document.querySelector('.section.foldable')
const title = window.document.querySelector('.section.foldable > h2')
title.click()
assert(foldableSection.classList.contains('folded'))
title.click()
assert(!foldableSection.classList.contains('folded'))
})