summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/test/headings.test.js
diff options
context:
space:
mode:
authorGravatar ktym4a <shoma@ktym4a.me> 2024-01-31 17:37:39 +0700
committerGravatar GitHub <noreply@github.com> 2024-01-31 10:37:39 +0000
commitbfc145b77875e0c91bc09d0b228f8ca8ef8e1023 (patch)
treed18432ead53a17d2e87ddb7e399220eae04b6d19 /packages/integrations/markdoc/test/headings.test.js
parent8dc7b39a6203af8426ea786bd1d8ed7fd9d35003 (diff)
downloadastro-bfc145b77875e0c91bc09d0b228f8ca8ef8e1023.tar.gz
astro-bfc145b77875e0c91bc09d0b228f8ca8ef8e1023.tar.zst
astro-bfc145b77875e0c91bc09d0b228f8ca8ef8e1023.zip
chore(@astrojs/markdoc): use Node.js for testing (#9897)
Diffstat (limited to 'packages/integrations/markdoc/test/headings.test.js')
-rw-r--r--packages/integrations/markdoc/test/headings.test.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/packages/integrations/markdoc/test/headings.test.js b/packages/integrations/markdoc/test/headings.test.js
index 5468e8c6b..b87f6408e 100644
--- a/packages/integrations/markdoc/test/headings.test.js
+++ b/packages/integrations/markdoc/test/headings.test.js
@@ -1,6 +1,7 @@
import { parseHTML } from 'linkedom';
-import { expect } from 'chai';
import { loadFixture } from '../../../astro/test/test-utils.js';
+import assert from 'node:assert/strict';
+import { after, before, describe, it } from 'node:test';
async function getFixture(name) {
return await loadFixture({
@@ -195,20 +196,20 @@ const depthToHeadingMap = {
/** @param {Document} document */
function idTest(document) {
for (const [depth, info] of Object.entries(depthToHeadingMap)) {
- expect(document.querySelector(`h${depth}`)?.getAttribute('id')).to.equal(info.slug);
+ assert.equal(document.querySelector(`h${depth}`)?.getAttribute('id'), info.slug);
}
}
/** @param {Document} document */
function tocTest(document) {
const toc = document.querySelector('[data-toc] > ul');
- expect(toc.children).to.have.lengthOf(Object.keys(depthToHeadingMap).length);
+ assert.equal(toc.children.length, Object.keys(depthToHeadingMap).length);
for (const [depth, info] of Object.entries(depthToHeadingMap)) {
const linkEl = toc.querySelector(`a[href="#${info.slug}"]`);
- expect(linkEl).to.exist;
- expect(linkEl.getAttribute('data-depth')).to.equal(depth);
- expect(linkEl.textContent.trim()).to.equal(info.text);
+ assert.ok(linkEl);
+ assert.equal(linkEl.getAttribute('data-depth'), depth);
+ assert.equal(linkEl.textContent.trim(), info.text);
}
}
@@ -217,6 +218,6 @@ function astroComponentTest(document) {
const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
for (const heading of headings) {
- expect(heading.hasAttribute('data-custom-heading')).to.be.true;
+ assert.equal(heading.hasAttribute('data-custom-heading'), true);
}
}