diff --git a/packages/astro/test/astro-markdown-shiki.test.js b/packages/astro/test/astro-markdown-shiki.nodetest.js
similarity index 50%
rename from packages/astro/test/astro-markdown-shiki.test.js
rename to packages/astro/test/astro-markdown-shiki.nodetest.js
index 459fc64645..6f9b9a65e3 100644
--- a/packages/astro/test/astro-markdown-shiki.test.js
+++ b/packages/astro/test/astro-markdown-shiki.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import assert from 'node:assert/strict';
+import { describe, before, it } from 'node:test';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
@@ -16,11 +17,12 @@ describe('Astro Markdown Shiki', () => {
const $ = cheerio.load(html);
// There should be no HTML from Prism
- expect($('.token')).to.have.lengthOf(0);
+ assert.strictEqual($('.token').length, 0);
- expect($('pre')).to.have.lengthOf(2);
- expect($('pre').hasClass('astro-code')).to.equal(true);
- expect($('pre').attr().style).to.equal(
+ assert.strictEqual($('pre').length, 2);
+ assert.ok($('pre').hasClass('astro-code'));
+ assert.strictEqual(
+ $('pre').attr().style,
'background-color:#24292e;color:#e1e4e8; overflow-x: auto;'
);
});
@@ -29,8 +31,8 @@ describe('Astro Markdown Shiki', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
const diffBlockHtml = $('pre').last().html();
- expect(diffBlockHtml).to.contain(`+`);
- expect(diffBlockHtml).to.contain(`-`);
+ assert.ok(diffBlockHtml.includes(`+`));
+ assert.ok(diffBlockHtml.includes(`-`));
});
});
@@ -47,9 +49,10 @@ describe('Astro Markdown Shiki', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
- expect($('pre')).to.have.lengthOf(1);
- expect($('pre').hasClass('astro-code')).to.equal(true);
- expect($('pre').attr().style).to.equal(
+ assert.strictEqual($('pre').length, 1);
+ assert.ok($('pre').hasClass('astro-code'));
+ assert.strictEqual(
+ $('pre').attr().style,
'background-color:#fff;color:#24292e; overflow-x: auto;'
);
});
@@ -67,9 +70,10 @@ describe('Astro Markdown Shiki', () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
- expect($('pre')).to.have.lengthOf(1);
- expect($('pre').hasClass('astro-code')).to.equal(true);
- expect($('pre').attr().style).to.equal(
+ assert.strictEqual($('pre').length, 1);
+ assert.ok($('pre').hasClass('astro-code'));
+ assert.strictEqual(
+ $('pre').attr().style,
'background-color:#FDFDFE;color:#4E5377; overflow-x: auto;'
);
});
@@ -89,69 +93,63 @@ describe('Astro Markdown Shiki', () => {
const $ = cheerio.load(html);
const segments = $('.line').get(6).children;
- expect(segments).to.have.lengthOf(2);
- expect(segments[0].attribs.style).to.be.equal('color:#79B8FF');
- expect(segments[1].attribs.style).to.be.equal('color:#E1E4E8');
+ assert.strictEqual(segments.length, 2);
+ assert.strictEqual(segments[0].attribs.style, 'color:#79B8FF');
+ assert.strictEqual(segments[1].attribs.style, 'color:#E1E4E8');
const unknownLang = $('.astro-code').get(1);
- expect(unknownLang.attribs.style).to.contain('background-color:#24292e;color:#e1e4e8;');
+ assert.ok(unknownLang.attribs.style.includes('background-color:#24292e;color:#e1e4e8;'));
});
});
- describe('Wrap', () => {
- describe('wrap = true', () => {
+ describe('Wrapping behaviours', () => {
+ let fixtures = {
+ ifTrue: null,
+ ifFalse: null,
+ ifNull: null,
+ };
+
+ before(async () => {
+ fixtures.ifTrue = await loadFixture({
+ root: './fixtures/astro-markdown-shiki/wrap-true/',
+ });
+ fixtures.ifFalse = await loadFixture({
+ root: './fixtures/astro-markdown-shiki/wrap-false/',
+ });
+ fixtures.ifNull = await loadFixture({
+ root: './fixtures/astro-markdown-shiki/wrap-null/',
+ });
+ await fixtures.ifTrue.build();
+ await fixtures.ifFalse.build();
+ await fixtures.ifNull.build();
+ });
+
+ it('Markdown file with wrap = true', async () => {
const style =
'background-color:#24292e;color:#e1e4e8; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;';
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/wrap-true/' });
- await fixture.build();
- });
-
- it('Markdown file', async () => {
- const html = await fixture.readFile('/index.html');
- const $ = cheerio.load(html);
-
- expect($('pre')).to.have.lengthOf(1);
- expect($('pre').attr('style')).to.equal(style);
- });
- });
- });
-
- describe('wrap = false', () => {
- const style = 'background-color:#24292e;color:#e1e4e8; overflow-x: auto;';
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/wrap-false/' });
- await fixture.build();
- });
-
- it('Markdown file', async () => {
- const html = await fixture.readFile('/index.html');
+ const html = await fixtures.ifTrue.readFile('/index.html');
const $ = cheerio.load(html);
- expect($('pre')).to.have.lengthOf(1);
- expect($('pre').attr('style')).to.equal(style);
- });
- });
-
- describe('wrap = null', () => {
- const style = 'background-color:#24292e;color:#e1e4e8';
- let fixture;
-
- before(async () => {
- fixture = await loadFixture({ root: './fixtures/astro-markdown-shiki/wrap-null/' });
- await fixture.build();
+ assert.strictEqual($('pre').length, 1);
+ assert.strictEqual($('pre').attr('style'), style);
});
- it('Markdown file', async () => {
- const html = await fixture.readFile('/index.html');
+ it('Markdown file with wrap = false', async () => {
+ const style = 'background-color:#24292e;color:#e1e4e8; overflow-x: auto;';
+ const html = await fixtures.ifFalse.readFile('/index.html');
const $ = cheerio.load(html);
- expect($('pre')).to.have.lengthOf(1);
- expect($('pre').attr('style')).to.equal(style);
+ assert.strictEqual($('pre').length, 1);
+ assert.strictEqual($('pre').attr('style'), style);
+ });
+
+ it('Markdown file with wrap = null', async () => {
+ const style = 'background-color:#24292e;color:#e1e4e8';
+ const html = await fixtures.ifNull.readFile('/index.html');
+ const $ = cheerio.load(html);
+
+ assert.strictEqual($('pre').length, 1);
+ assert.strictEqual($('pre').attr('style'), style);
});
});
});