diff --git a/tests/js/foldable-sections.test.js b/tests/js/foldable-sections.test.js
new file mode 100644
index 0000000..b325735
--- /dev/null
+++ b/tests/js/foldable-sections.test.js
@@ -0,0 +1,19 @@
+const assert = require('assert')
+const { loadDom } = require('./test-utils')
+
+test('test foldable sections', async () => {
+ const { window } = await loadDom(`
+
+
Section Title
+
+ `)
+
+ 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'))
+})
diff --git a/tests/js/test-utils.js b/tests/js/test-utils.js
new file mode 100644
index 0000000..93c8678
--- /dev/null
+++ b/tests/js/test-utils.js
@@ -0,0 +1,31 @@
+const path = require('path')
+const { JSDOM } = require('jsdom')
+
+async function loadDom (content) {
+ const dom = new JSDOM(`
+
+
+
+ ${content}
+
+
+
+
+ `, {
+ runScripts: 'dangerously',
+ resources: 'usable'
+ })
+
+ await new Promise((resolve, reject) => {
+ dom.window.document.addEventListener('test:ready', () => {
+ resolve()
+ })
+ })
+
+ return dom
+};
+
+module.exports = { loadDom }
+