mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
parent
141f2fb757
commit
e845fb2eaa
18 changed files with 265 additions and 236 deletions
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -20,7 +21,7 @@ describe('build.format', () => {
|
|||
it('relative urls created point to sibling folders', async () => {
|
||||
let html = await fixture.readFile('/nested/page/index.html');
|
||||
let $ = cheerio.load(html);
|
||||
expect($('#another').attr('href')).to.equal('/nested/page/another/');
|
||||
assert.equal($('#another').attr('href'), '/nested/page/another/');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -45,7 +46,7 @@ describe('build.format', () => {
|
|||
it('relative urls created point to sibling folders', async () => {
|
||||
let html = await fixture.readFile('/nested/page.html');
|
||||
let $ = cheerio.load(html);
|
||||
expect($('#another').attr('href')).to.equal('/nested/another/');
|
||||
assert.equal($('#another').attr('href'), '/nested/another/');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -80,13 +81,13 @@ describe('build.format', () => {
|
|||
it('relative urls created point to sibling folders', async () => {
|
||||
let html = await fixture.readFile('/en/nested/page.html');
|
||||
let $ = cheerio.load(html);
|
||||
expect($('#another').attr('href')).to.equal('/test/en/nested/another/');
|
||||
assert.equal($('#another').attr('href'), '/test/en/nested/another/');
|
||||
});
|
||||
|
||||
it('index files are written as index.html', async () => {
|
||||
let html = await fixture.readFile('/en/nested/index.html');
|
||||
let $ = cheerio.load(html);
|
||||
expect($('h1').text()).to.equal('Testing');
|
||||
assert.equal($('h1').text(), 'Testing');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import { load as cheerioLoad } from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -18,12 +19,12 @@ describe('Page-level styles', () => {
|
|||
it("Doesn't add page styles for a page without style imports", async () => {
|
||||
let html = await fixture.readFile('/index.html');
|
||||
let $ = await cheerioLoad(html);
|
||||
expect($('link').length).to.equal(0);
|
||||
assert.equal($('link').length, 0);
|
||||
});
|
||||
|
||||
it('Does add page styles for pages with style imports (or deps)', async () => {
|
||||
let html = await fixture.readFile('/blog/index.html');
|
||||
let $ = await cheerioLoad(html);
|
||||
expect($('link').length).to.equal(1);
|
||||
assert.equal($('link').length, 1);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -22,14 +23,16 @@ describe('Component parallelization', () => {
|
|||
);
|
||||
|
||||
const renderStartWithin = Math.max(...startTimes) - Math.min(...startTimes);
|
||||
expect(renderStartWithin).to.be.lessThan(
|
||||
40, // in theory, this should be 0, but add 40ms tolerance for CI
|
||||
assert.equal(
|
||||
renderStartWithin < 40,
|
||||
true, // in theory, this should be 0, but add 40ms tolerance for CI
|
||||
"The components didn't start rendering in parallel"
|
||||
);
|
||||
|
||||
const totalRenderTime = Math.max(...finishTimes) - Math.min(...startTimes);
|
||||
expect(totalRenderTime).to.be.lessThan(
|
||||
80, // max component delay is 40ms, add 40ms tolerance for CI
|
||||
assert.equal(
|
||||
totalRenderTime < 80,
|
||||
true, // max component delay is 40ms, add 40ms tolerance for CI
|
||||
'The total render time was significantly longer than the max component delay'
|
||||
);
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it, after } from 'node:test';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('Partials', () => {
|
||||
|
@ -25,7 +26,7 @@ describe('Partials', () => {
|
|||
|
||||
it('is only the written HTML', async () => {
|
||||
const html = await fixture.fetch('/partials/item/').then((res) => res.text());
|
||||
expect(html.startsWith('<li')).to.equal(true);
|
||||
assert.equal(html.startsWith('<li'), true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -36,12 +37,12 @@ describe('Partials', () => {
|
|||
|
||||
it('is only the written HTML', async () => {
|
||||
const html = await fixture.readFile('/partials/item/index.html');
|
||||
expect(html.startsWith('<li>')).to.equal(true);
|
||||
assert.equal(html.startsWith('<li>'), true);
|
||||
});
|
||||
|
||||
it('Works with mdx', async () => {
|
||||
const html = await fixture.readFile('/partials/docs/index.html');
|
||||
expect(html.startsWith('<h1')).to.equal(true);
|
||||
assert.equal(html.startsWith('<h1'), true);
|
||||
});
|
||||
});
|
||||
});
|
59
packages/astro/test/postcss.nodetest.js
Normal file
59
packages/astro/test/postcss.nodetest.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import eol from 'eol';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('PostCSS', () => {
|
||||
let fixture;
|
||||
let bundledCSS;
|
||||
before(
|
||||
async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/postcss',
|
||||
// test suite was authored when inlineStylesheets defaulted to never
|
||||
build: { inlineStylesheets: 'never' },
|
||||
});
|
||||
await fixture.build();
|
||||
|
||||
// get bundled CSS (will be hashed, hence DOM query)
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const bundledCSSHREF = $('link[rel=stylesheet][href^=/_astro/]').attr('href');
|
||||
bundledCSS = (await fixture.readFile(bundledCSSHREF.replace(/^\/?/, '/')))
|
||||
.replace(/\s/g, '')
|
||||
.replace('/n', '');
|
||||
},
|
||||
{ timeout: 45000 }
|
||||
);
|
||||
|
||||
/** All test cases check whether nested styles (i.e. &.nested {}) are correctly transformed */
|
||||
it('works in Astro page styles', () => {
|
||||
assert.match(bundledCSS, /\.astro-page\[data-astro-cid-.*?\]\.nested/);
|
||||
});
|
||||
|
||||
it('works in Astro component styles', () => {
|
||||
assert.match(bundledCSS, /\.astro-component\[data-astro-cid-.*?\]\.nested/);
|
||||
});
|
||||
|
||||
it('works in JSX', () => {
|
||||
assert.match(bundledCSS, /\.solid(\.(w|-)*)*\.nested/);
|
||||
});
|
||||
|
||||
it('works in Vue', () => {
|
||||
assert.match(bundledCSS, /\.vue(\.(w|-)*)*\.nested/);
|
||||
});
|
||||
|
||||
it('works in Svelte', () => {
|
||||
assert.match(bundledCSS, /\.svelte(\.(w|-)*)*\.nested/);
|
||||
});
|
||||
|
||||
it('ignores CSS in public/', async () => {
|
||||
const publicCSS = (await fixture.readFile('/global.css'))
|
||||
.trim()
|
||||
.replace(/\s/g, '')
|
||||
.replace('/n', '');
|
||||
// neither minified nor prefixed
|
||||
assert.equal(eol.lf(publicCSS), '.global{appearance:none;}');
|
||||
});
|
||||
});
|
|
@ -1,56 +0,0 @@
|
|||
import { expect } from 'chai';
|
||||
import * as cheerio from 'cheerio';
|
||||
import eol from 'eol';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('PostCSS', function () {
|
||||
let fixture;
|
||||
let bundledCSS;
|
||||
before(async () => {
|
||||
this.timeout(45000); // test needs a little more time in CI
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/postcss',
|
||||
// test suite was authored when inlineStylesheets defaulted to never
|
||||
build: { inlineStylesheets: 'never' },
|
||||
});
|
||||
await fixture.build();
|
||||
|
||||
// get bundled CSS (will be hashed, hence DOM query)
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const bundledCSSHREF = $('link[rel=stylesheet][href^=/_astro/]').attr('href');
|
||||
bundledCSS = (await fixture.readFile(bundledCSSHREF.replace(/^\/?/, '/')))
|
||||
.replace(/\s/g, '')
|
||||
.replace('/n', '');
|
||||
});
|
||||
|
||||
/** All test cases check whether nested styles (i.e. &.nested {}) are correctly transformed */
|
||||
it('works in Astro page styles', () => {
|
||||
expect(bundledCSS).to.match(/\.astro-page\[data-astro-cid-.*?\]\.nested/);
|
||||
});
|
||||
|
||||
it('works in Astro component styles', () => {
|
||||
expect(bundledCSS).to.match(/\.astro-component\[data-astro-cid-.*?\]\.nested/);
|
||||
});
|
||||
|
||||
it('works in JSX', () => {
|
||||
expect(bundledCSS).to.match(/\.solid(\.(w|-)*)*\.nested/);
|
||||
});
|
||||
|
||||
it('works in Vue', () => {
|
||||
expect(bundledCSS).to.match(/\.vue(\.(w|-)*)*\.nested/);
|
||||
});
|
||||
|
||||
it('works in Svelte', () => {
|
||||
expect(bundledCSS).to.match(/\.svelte(\.(w|-)*)*\.nested/);
|
||||
});
|
||||
|
||||
it('ignores CSS in public/', async () => {
|
||||
const publicCSS = (await fixture.readFile('/global.css'))
|
||||
.trim()
|
||||
.replace(/\s/g, '')
|
||||
.replace('/n', '');
|
||||
// neither minified nor prefixed
|
||||
expect(eol.lf(publicCSS)).to.equal(`.global{appearance:none;}`);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it, after } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -29,7 +30,7 @@ describe('Preact compat component', () => {
|
|||
const html = await res.text();
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
expect($('#counter-text').text()).to.be.eq('0');
|
||||
assert.equal($('#counter-text').text(), '0');
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -42,7 +43,7 @@ describe('Preact compat component', () => {
|
|||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
expect($('#counter-text').text()).to.be.eq('0');
|
||||
assert.equal($('#counter-text').text(), '0');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -18,7 +19,7 @@ describe('Preact component', () => {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
// test 1: Can use class components
|
||||
expect($('#class-component')).to.have.lengthOf(1);
|
||||
assert.equal($('#class-component').length, 1);
|
||||
});
|
||||
|
||||
it('Can load function component', async () => {
|
||||
|
@ -26,9 +27,9 @@ describe('Preact component', () => {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
// test 1: Can use function components
|
||||
expect($('#fn-component')).to.have.lengthOf(1);
|
||||
assert.equal($('#fn-component').length, 1);
|
||||
// test 2: Can use function components
|
||||
expect($('#arrow-fn-component')).to.have.lengthOf(1);
|
||||
assert.equal($('#arrow-fn-component').length, 1);
|
||||
});
|
||||
|
||||
it('Can load TS component', async () => {
|
||||
|
@ -36,13 +37,13 @@ describe('Preact component', () => {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
// test 1: Can use TS components
|
||||
expect($('.ts-component')).to.have.lengthOf(1);
|
||||
assert.equal($('.ts-component').length, 1);
|
||||
});
|
||||
|
||||
it('Can use hooks', async () => {
|
||||
const html = await fixture.readFile('/hooks/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('#world')).to.have.lengthOf(1);
|
||||
assert.equal($('#world').length, 1);
|
||||
});
|
||||
|
||||
it('Can export a Fragment', async () => {
|
||||
|
@ -50,7 +51,7 @@ describe('Preact component', () => {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
// test 1: nothing rendered but it didn’t throw
|
||||
expect($('body').children()).to.have.lengthOf(0);
|
||||
assert.equal($('body').children().length, 0);
|
||||
});
|
||||
|
||||
it('Can use a pragma comment', async () => {
|
||||
|
@ -58,8 +59,8 @@ describe('Preact component', () => {
|
|||
const $ = cheerio.load(html);
|
||||
|
||||
// test 1: rendered the PragmaComment component
|
||||
expect($('.pragma-comment')).to.have.lengthOf(1);
|
||||
expect($('.pragma-comment-tsx')).to.have.lengthOf(1);
|
||||
assert.equal($('.pragma-comment').length, 1);
|
||||
assert.equal($('.pragma-comment-tsx').length, 1);
|
||||
});
|
||||
|
||||
// In moving over to Vite, the jsx-runtime import is now obscured. TODO: update the method of finding this.
|
||||
|
@ -79,24 +80,24 @@ describe('Preact component', () => {
|
|||
const jsxRuntime = component.imports.filter((i) => i.specifier.includes('jsx-runtime'));
|
||||
|
||||
// test 1: preact/jsx-runtime is used for the component
|
||||
expect(jsxRuntime).to.be.ok;
|
||||
assert.ok(jsxRuntime);
|
||||
});
|
||||
|
||||
it('Can use shared signals between islands', async () => {
|
||||
const html = await fixture.readFile('/signals/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('.preact-signal')).to.have.a.lengthOf(2);
|
||||
assert.equal($('.preact-signal').length, 2);
|
||||
|
||||
const sigs1Raw = $($('astro-island')[0]).attr('data-preact-signals');
|
||||
const sigs2Raw = $($('astro-island')[1]).attr('data-preact-signals');
|
||||
|
||||
expect(sigs1Raw).to.not.be.undefined;
|
||||
expect(sigs2Raw).to.not.be.undefined;
|
||||
assert.notEqual(sigs1Raw, undefined);
|
||||
assert.notEqual(sigs2Raw, undefined);
|
||||
|
||||
const sigs1 = JSON.parse(sigs1Raw);
|
||||
const sigs2 = JSON.parse(sigs2Raw);
|
||||
|
||||
expect(sigs1.count).to.not.be.undefined;
|
||||
expect(sigs1.count).to.equal(sigs2.count);
|
||||
assert.notEqual(sigs1.count, undefined);
|
||||
assert.equal(sigs1.count, sigs2.count);
|
||||
});
|
||||
});
|
|
@ -1,8 +1,9 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it, after } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
describe('Preview Routing', function () {
|
||||
describe('Preview Routing', () => {
|
||||
describe('build format: directory', () => {
|
||||
describe('Subpath without trailing slash and trailingSlash: never', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
|
@ -33,34 +34,34 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root with trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog/');
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.redirected).to.equal(false);
|
||||
assert.equal(response.status, 200);
|
||||
assert.equal(response.redirected, false);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root without trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog');
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.redirected).to.equal(false);
|
||||
assert.equal(response.status, 200);
|
||||
assert.equal(response.redirected, false);
|
||||
});
|
||||
|
||||
it('404 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -90,37 +91,37 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root with trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading subpath root without trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading another page with subpath not used', async () => {
|
||||
const response = await fixture.fetch('/blog/another');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -150,37 +151,37 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root with trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root without trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath not used', async () => {
|
||||
const response = await fixture.fetch('/blog/another');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -209,13 +210,13 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('renders custom 404 for /a', async () => {
|
||||
const res = await fixture.fetch('/a');
|
||||
expect(res.status).to.equal(404);
|
||||
assert.equal(res.status, 404);
|
||||
|
||||
const html = await res.text();
|
||||
$ = cheerio.load(html);
|
||||
|
||||
expect($('h1').text()).to.equal('Page not found');
|
||||
expect($('p').text()).to.equal('This 404 is a static HTML file.');
|
||||
assert.equal($('h1').text(), 'Page not found');
|
||||
assert.equal($('p').text(), 'This 404 is a static HTML file.');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -250,34 +251,34 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root with trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog/');
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.redirected).to.equal(false);
|
||||
assert.equal(response.status, 200);
|
||||
assert.equal(response.redirected, false);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root without trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog');
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.redirected).to.equal(false);
|
||||
assert.equal(response.status, 200);
|
||||
assert.equal(response.redirected, false);
|
||||
});
|
||||
|
||||
it('404 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -310,37 +311,37 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root with trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading subpath root without trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading another page with subpath not used', async () => {
|
||||
const response = await fixture.fetch('/blog/another');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -373,37 +374,37 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root with trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading subpath root without trailing slash', async () => {
|
||||
const response = await fixture.fetch('/blog');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath not used', async () => {
|
||||
const response = await fixture.fetch('/blog/another');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1/');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -436,27 +437,27 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('404 when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
|
||||
it('200 when loading subpath with index.html', async () => {
|
||||
const response = await fixture.fetch('/blog/index.html');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading another page with subpath used', async () => {
|
||||
const response = await fixture.fetch('/blog/another.html');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('200 when loading dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/1.html');
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('404 when loading invalid dynamic route', async () => {
|
||||
const response = await fixture.fetch('/blog/2.html');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -488,13 +489,13 @@ describe('Preview Routing', function () {
|
|||
|
||||
it('renders custom 404 for /a', async () => {
|
||||
const res = await fixture.fetch('/a');
|
||||
expect(res.status).to.equal(404);
|
||||
assert.equal(res.status, 404);
|
||||
|
||||
const html = await res.text();
|
||||
$ = cheerio.load(html);
|
||||
|
||||
expect($('h1').text()).to.equal('Page not found');
|
||||
expect($('p').text()).to.equal('This 404 is a static HTML file.');
|
||||
assert.equal($('h1').text(), 'Page not found');
|
||||
assert.equal($('p').text(), 'This 404 is a static HTML file.');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it, after } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -6,6 +7,7 @@ describe('Public dev with base', () => {
|
|||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
let $;
|
||||
let devServer;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
|
@ -13,38 +15,42 @@ describe('Public dev with base', () => {
|
|||
site: 'http://example.com/',
|
||||
base: '/blog',
|
||||
});
|
||||
await fixture.startDevServer();
|
||||
devServer = await fixture.startDevServer();
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await devServer.stop();
|
||||
});
|
||||
|
||||
it('200 when loading /@vite/client', async () => {
|
||||
const response = await fixture.fetch('/@vite/client', {
|
||||
redirect: 'manual',
|
||||
});
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
const content = await response.text();
|
||||
expect(content).to.contain('vite');
|
||||
assert.equal(content.includes('vite'), true);
|
||||
});
|
||||
|
||||
it('200 when loading /blog/twitter.png', async () => {
|
||||
const response = await fixture.fetch('/blog/twitter.png', {
|
||||
redirect: 'manual',
|
||||
});
|
||||
expect(response.status).to.equal(200);
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
it('custom 404 page when loading /blog/blog/', async () => {
|
||||
const response = await fixture.fetch('/blog/blog/');
|
||||
const html = await response.text();
|
||||
$ = cheerio.load(html);
|
||||
expect($('h1').text()).to.equal('404');
|
||||
assert.equal($('h1').text(), '404');
|
||||
});
|
||||
|
||||
it('default 404 hint page when loading /', async () => {
|
||||
const response = await fixture.fetch('/');
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
const html = await response.text();
|
||||
$ = cheerio.load(html);
|
||||
expect($('a').first().text()).to.equal('/blog');
|
||||
assert.equal($('a').first().text(), '/blog');
|
||||
});
|
||||
|
||||
it('default 404 page when loading /none/', async () => {
|
||||
|
@ -53,10 +59,10 @@ describe('Public dev with base', () => {
|
|||
accept: 'text/html,*/*',
|
||||
},
|
||||
});
|
||||
expect(response.status).to.equal(404);
|
||||
assert.equal(response.status, 404);
|
||||
const html = await response.text();
|
||||
$ = cheerio.load(html);
|
||||
expect($('h1').text()).to.equal('404: Not found');
|
||||
expect($('pre').text()).to.equal('Path: /none/');
|
||||
assert.equal($('h1').text(), '404: Not found');
|
||||
assert.equal($('pre').text(), 'Path: /none/');
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -14,7 +15,7 @@ describe('Solid app with some React components', () => {
|
|||
it('Reads jsxImportSource from tsconfig', async () => {
|
||||
let html = await fixture.readFile('/index.html');
|
||||
let $ = cheerio.load(html);
|
||||
expect($('#example-solid').text()).to.equal('example solidjs component');
|
||||
expect($('#example-react').text()).to.equal('example react component');
|
||||
assert.equal($('#example-solid').text(), 'example solidjs component');
|
||||
assert.equal($('#example-react').text(), 'example react component');
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -42,12 +43,15 @@ describe('react-jsx-export', () => {
|
|||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
|
||||
ids.forEach((id) => {
|
||||
expect($(`#${id}`).text()).to.equal('Example');
|
||||
});
|
||||
for (const id of ids) {
|
||||
assert.equal($(`#${id}`).text(), 'Example');
|
||||
}
|
||||
});
|
||||
|
||||
it('Cannot output React Invalid Hook warning', async () => {
|
||||
expect(logs.every((log) => log.message.indexOf(reactInvalidHookWarning) === -1)).to.be.true;
|
||||
assert.equal(
|
||||
logs.every((log) => log.message.indexOf(reactInvalidHookWarning) === -1),
|
||||
true
|
||||
);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it, after } from 'node:test';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
import testAdapter from './test-adapter.js';
|
||||
|
||||
|
@ -31,17 +32,17 @@ describe('Astro.redirect', () => {
|
|||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/secret');
|
||||
const response = await app.render(request);
|
||||
expect(response.status).to.equal(302);
|
||||
expect(response.headers.get('location')).to.equal('/login');
|
||||
assert.equal(response.status, 302);
|
||||
assert.equal(response.headers.get('location'), '/login');
|
||||
});
|
||||
|
||||
// ref: https://github.com/withastro/astro/pull/9287
|
||||
// ref: https://github.com/withastro/astro/pull/9287#discussion_r1420739810
|
||||
it.skip('Ignores external redirect', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/external/redirect');
|
||||
const response = await app.render(request);
|
||||
expect(response.status).to.equal(404);
|
||||
expect(response.headers.get('location')).to.equal(null);
|
||||
assert.equal(response.status, 404);
|
||||
assert.equal(response.headers.get('location'), null);
|
||||
});
|
||||
|
||||
it('Warns when used inside a component', async () => {
|
||||
|
@ -50,9 +51,10 @@ describe('Astro.redirect', () => {
|
|||
const response = await app.render(request);
|
||||
try {
|
||||
await response.text();
|
||||
expect(false).to.equal(true);
|
||||
assert.equal(false, true);
|
||||
} catch (e) {
|
||||
expect(e.message).to.equal(
|
||||
assert.equal(
|
||||
e.message,
|
||||
'The response has already been sent to the browser and cannot be altered.'
|
||||
);
|
||||
}
|
||||
|
@ -63,8 +65,8 @@ describe('Astro.redirect', () => {
|
|||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/api/redirect');
|
||||
const response = await app.render(request);
|
||||
expect(response.status).to.equal(301);
|
||||
expect(response.headers.get('Location')).to.equal('/test');
|
||||
assert.equal(response.status, 301);
|
||||
assert.equal(response.headers.get('Location'), '/test');
|
||||
});
|
||||
|
||||
it('Uses 308 for non-GET methods', async () => {
|
||||
|
@ -73,28 +75,28 @@ describe('Astro.redirect', () => {
|
|||
method: 'POST',
|
||||
});
|
||||
const response = await app.render(request);
|
||||
expect(response.status).to.equal(308);
|
||||
assert.equal(response.status, 308);
|
||||
});
|
||||
|
||||
it('Forwards params to the target path - single param', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/source/x');
|
||||
const response = await app.render(request);
|
||||
expect(response.headers.get('Location')).to.equal('/not-verbatim/target1/x');
|
||||
assert.equal(response.headers.get('Location'), '/not-verbatim/target1/x');
|
||||
});
|
||||
|
||||
it('Forwards params to the target path - multiple params', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/source/x/y');
|
||||
const response = await app.render(request);
|
||||
expect(response.headers.get('Location')).to.equal('/not-verbatim/target2/x/y');
|
||||
assert.equal(response.headers.get('Location'), '/not-verbatim/target2/x/y');
|
||||
});
|
||||
|
||||
it('Forwards params to the target path - spread param', async () => {
|
||||
const app = await fixture.loadTestAdapterApp();
|
||||
const request = new Request('http://example.com/source/x/y/z');
|
||||
const response = await app.render(request);
|
||||
expect(response.headers.get('Location')).to.equal('/not-verbatim/target3/x/y/z');
|
||||
assert.equal(response.headers.get('Location'), '/not-verbatim/target3/x/y/z');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -126,75 +128,75 @@ describe('Astro.redirect', () => {
|
|||
|
||||
it("Minifies the HTML emitted when a page that doesn't exist is emitted", async () => {
|
||||
const html = await fixture.readFile('/old/index.html');
|
||||
expect(html).to.not.include('\n');
|
||||
assert.equal(html.includes('\n'), false);
|
||||
});
|
||||
|
||||
it('Includes the meta refresh tag in Astro.redirect pages', async () => {
|
||||
const html = await fixture.readFile('/secret/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/login');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/login'), true);
|
||||
});
|
||||
|
||||
it('Includes the meta noindex tag', async () => {
|
||||
const html = await fixture.readFile('/secret/index.html');
|
||||
expect(html).to.include('name="robots');
|
||||
expect(html).to.include('content="noindex');
|
||||
assert.equal(html.includes('name="robots'), true);
|
||||
assert.equal(html.includes('content="noindex'), true);
|
||||
});
|
||||
|
||||
it('Includes a link to the new pages for bots to follow', async () => {
|
||||
const html = await fixture.readFile('/secret/index.html');
|
||||
expect(html).to.include('<a href="/login">');
|
||||
assert.equal(html.includes('<a href="/login">'), true);
|
||||
});
|
||||
|
||||
it('Includes a canonical link', async () => {
|
||||
const html = await fixture.readFile('/secret/index.html');
|
||||
expect(html).to.include('<link rel="canonical" href="/login">');
|
||||
assert.equal(html.includes('<link rel="canonical" href="/login">'), true);
|
||||
});
|
||||
|
||||
it('A 302 status generates a "temporary redirect" through a short delay', async () => {
|
||||
// https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh
|
||||
const html = await fixture.readFile('/secret/index.html');
|
||||
expect(html).to.include('content="2;url=/login"');
|
||||
assert.equal(html.includes('content="2;url=/login"'), true);
|
||||
});
|
||||
|
||||
it('Includes the meta refresh tag in `redirect` config pages', async () => {
|
||||
let html = await fixture.readFile('/one/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/test');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/test'), true);
|
||||
|
||||
html = await fixture.readFile('/two/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/test');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/test'), true);
|
||||
|
||||
html = await fixture.readFile('/three/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/test');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/test'), true);
|
||||
|
||||
html = await fixture.readFile('/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/test');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/test'), true);
|
||||
});
|
||||
|
||||
it('Generates page for dynamic routes', async () => {
|
||||
let html = await fixture.readFile('/blog/one/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/articles/one');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/articles/one'), true);
|
||||
|
||||
html = await fixture.readFile('/blog/two/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/articles/two');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/articles/two'), true);
|
||||
});
|
||||
|
||||
it('Generates redirect pages for redirects created by middleware', async () => {
|
||||
let html = await fixture.readFile('/middleware-redirect/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/test');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/test'), true);
|
||||
});
|
||||
|
||||
it('falls back to spread rule when dynamic rules should not match', async () => {
|
||||
const html = await fixture.readFile('/more/old/welcome/world/index.html');
|
||||
expect(html).to.include('http-equiv="refresh');
|
||||
expect(html).to.include('url=/more/new/welcome/world');
|
||||
assert.equal(html.includes('http-equiv="refresh'), true);
|
||||
assert.equal(html.includes('url=/more/new/welcome/world'), true);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -224,23 +226,23 @@ describe('Astro.redirect', () => {
|
|||
let res = await fixture.fetch('/one', {
|
||||
redirect: 'manual',
|
||||
});
|
||||
expect(res.status).to.equal(301);
|
||||
expect(res.headers.get('Location')).to.equal('/');
|
||||
assert.equal(res.status, 301);
|
||||
assert.equal(res.headers.get('Location'), '/');
|
||||
});
|
||||
|
||||
it('performs dynamic redirects', async () => {
|
||||
const response = await fixture.fetch('/more/old/hello', { redirect: 'manual' });
|
||||
expect(response.headers.get('Location')).to.equal('/more/hello');
|
||||
assert.equal(response.headers.get('Location'), '/more/hello');
|
||||
});
|
||||
|
||||
it('performs dynamic redirects with multiple params', async () => {
|
||||
const response = await fixture.fetch('/more/old/hello/world', { redirect: 'manual' });
|
||||
expect(response.headers.get('Location')).to.equal('/more/hello/world');
|
||||
assert.equal(response.headers.get('Location'), '/more/hello/world');
|
||||
});
|
||||
|
||||
it.skip('falls back to spread rule when dynamic rules should not match', async () => {
|
||||
const response = await fixture.fetch('/more/old/welcome/world', { redirect: 'manual' });
|
||||
expect(response.headers.get('Location')).to.equal('/more/new/welcome/world');
|
||||
assert.equal(response.headers.get('Location'), '/more/new/welcome/world');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -266,7 +268,7 @@ describe('Astro.redirect', () => {
|
|||
try {
|
||||
oneHtml = await fixture.readFile('/one/index.html');
|
||||
} catch {}
|
||||
expect(oneHtml).be.an('undefined');
|
||||
assert.equal(oneHtml, undefined);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -13,7 +14,7 @@ describe('Re-exported astro components with client components', () => {
|
|||
it('Is able to build and renders and stuff', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('astro-island').length).to.equal(1);
|
||||
expect($('astro-island').attr('component-export')).to.equal('One');
|
||||
assert.equal($('astro-island').length, 1);
|
||||
assert.equal($('astro-island').attr('component-export'), 'One');
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -21,7 +22,7 @@ describe('Remote CSS', () => {
|
|||
const relPath = $('link').attr('href');
|
||||
const css = await fixture.readFile(relPath);
|
||||
|
||||
expect(css).to.match(/https:\/\/unpkg.com\/open-props/);
|
||||
expect(css).to.match(/body/);
|
||||
assert.match(css, /https:\/\/unpkg.com\/open-props/);
|
||||
assert.match(css, /body/);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it } from 'node:test';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -20,6 +21,6 @@ describe('srcDir', () => {
|
|||
|
||||
const relPath = $('link').attr('href');
|
||||
const css = await fixture.readFile(relPath);
|
||||
expect(css).to.match(/body\{color:green\}/);
|
||||
assert.match(css, /body\{color:green\}/);
|
||||
});
|
||||
});
|
|
@ -1,4 +1,5 @@
|
|||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { before, describe, it, after } from 'node:test';
|
||||
import { load as cheerioLoad } from 'cheerio';
|
||||
import { loadFixture } from './test-utils.js';
|
||||
|
||||
|
@ -145,7 +146,7 @@ describe('Routing priority', () => {
|
|||
const htmlFile = isEndpoint ? url : `${appendForwardSlash(url)}index.html`;
|
||||
|
||||
if (fourOhFour) {
|
||||
expect(fixture.pathExists(htmlFile)).to.be.false;
|
||||
assert.equal(fixture.pathExists(htmlFile), false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -153,15 +154,15 @@ describe('Routing priority', () => {
|
|||
const $ = cheerioLoad(html);
|
||||
|
||||
if (h1) {
|
||||
expect($('h1').text()).to.equal(h1);
|
||||
assert.equal($('h1').text(), h1);
|
||||
}
|
||||
|
||||
if (p) {
|
||||
expect($('p').text()).to.equal(p);
|
||||
assert.equal($('p').text(), p);
|
||||
}
|
||||
|
||||
if (htmlMatch) {
|
||||
expect(html).to.equal(htmlMatch);
|
||||
assert.equal(html, htmlMatch);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -192,20 +193,20 @@ describe('Routing priority', () => {
|
|||
const $ = cheerioLoad(html);
|
||||
|
||||
if (fourOhFour) {
|
||||
expect($('title').text()).to.equal('404: Not Found');
|
||||
assert.equal($('title').text(), '404: Not Found');
|
||||
return;
|
||||
}
|
||||
|
||||
if (h1) {
|
||||
expect($('h1').text()).to.equal(h1);
|
||||
assert.equal($('h1').text(), h1);
|
||||
}
|
||||
|
||||
if (p) {
|
||||
expect($('p').text()).to.equal(p);
|
||||
assert.equal($('p').text(), p);
|
||||
}
|
||||
|
||||
if (htmlMatch) {
|
||||
expect(html).to.equal(htmlMatch);
|
||||
assert.equal(html, htmlMatch);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -218,20 +219,20 @@ describe('Routing priority', () => {
|
|||
const $ = cheerioLoad(html);
|
||||
|
||||
if (fourOhFour) {
|
||||
expect($('title').text()).to.equal('404: Not Found');
|
||||
assert.equal($('title').text(), '404: Not Found');
|
||||
return;
|
||||
}
|
||||
|
||||
if (h1) {
|
||||
expect($('h1').text()).to.equal(h1);
|
||||
assert.equal($('h1').text(), h1);
|
||||
}
|
||||
|
||||
if (p) {
|
||||
expect($('p').text()).to.equal(p);
|
||||
assert.equal($('p').text(), p);
|
||||
}
|
||||
|
||||
if (htmlMatch) {
|
||||
expect(html).to.equal(htmlMatch);
|
||||
assert.equal(html, htmlMatch);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -243,20 +244,20 @@ describe('Routing priority', () => {
|
|||
const $ = cheerioLoad(html);
|
||||
|
||||
if (fourOhFour) {
|
||||
expect($('title').text()).to.equal('404: Not Found');
|
||||
assert.equal($('title').text(), '404: Not Found');
|
||||
return;
|
||||
}
|
||||
|
||||
if (h1) {
|
||||
expect($('h1').text()).to.equal(h1);
|
||||
assert.equal($('h1').text(), h1);
|
||||
}
|
||||
|
||||
if (p) {
|
||||
expect($('p').text()).to.equal(p);
|
||||
assert.equal($('p').text(), p);
|
||||
}
|
||||
|
||||
if (htmlMatch) {
|
||||
expect(html).to.equal(htmlMatch);
|
||||
assert.equal(html, htmlMatch);
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue