summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/astro/package.json4
-rw-r--r--packages/astro/test/units/app/headers.nodetest.js (renamed from packages/astro/test/units/app/headers.test.js)22
-rw-r--r--packages/astro/test/units/assets/remote-pattern.nodetest.js116
-rw-r--r--packages/astro/test/units/assets/remote-pattern.test.js111
-rw-r--r--packages/astro/test/units/build/static-build.nodetest.js (renamed from packages/astro/test/units/build/static-build.test.js)11
-rw-r--r--packages/astro/test/units/compile/invalid-css.nodetest.js (renamed from packages/astro/test/units/compile/invalid-css.test.js)7
-rw-r--r--packages/astro/test/units/dev/base.nodetest.js (renamed from packages/astro/test/units/dev/base.test.js)11
-rw-r--r--packages/astro/test/units/dev/collections-mixed-content-errors.nodetest.js (renamed from packages/astro/test/units/dev/collections-mixed-content-errors.test.js)11
-rw-r--r--packages/astro/test/units/dev/collections-renderentry.nodetest.js (renamed from packages/astro/test/units/dev/collections-renderentry.test.js)23
-rw-r--r--packages/astro/test/units/dev/dev.nodetest.js (renamed from packages/astro/test/units/dev/dev.test.js)35
-rw-r--r--packages/astro/test/units/dev/head-injection.nodetest.js (renamed from packages/astro/test/units/dev/head-injection.test.js)12
-rw-r--r--packages/astro/test/units/dev/hydration.nodetest.js (renamed from packages/astro/test/units/dev/hydration.test.js)6
-rw-r--r--packages/astro/test/units/dev/restart.nodetest.js (renamed from packages/astro/test/units/dev/restart.test.js)23
-rw-r--r--packages/astro/test/units/dev/styles.nodetest.js (renamed from packages/astro/test/units/dev/styles.test.js)6
-rw-r--r--packages/astro/test/units/i18n/astro_i18n.nodetest.js (renamed from packages/astro/test/units/i18n/astro_i18n.test.js)913
-rw-r--r--packages/astro/test/units/integrations/api.nodetest.js (renamed from packages/astro/test/units/integrations/api.test.js)37
-rw-r--r--packages/astro/test/units/logger/locale.nodetest.js (renamed from packages/astro/test/units/logger/locale.test.js)7
-rw-r--r--packages/astro/test/units/render/chunk.nodetest.js (renamed from packages/astro/test/units/render/chunk.test.js)9
-rw-r--r--packages/astro/test/units/render/components.nodetest.js (renamed from packages/astro/test/units/render/components.test.js)21
-rw-r--r--packages/astro/test/units/render/head.nodetest.js (renamed from packages/astro/test/units/render/head.test.js)14
-rw-r--r--packages/astro/test/units/render/jsx.nodetest.js (renamed from packages/astro/test/units/render/jsx.test.js)20
-rw-r--r--packages/astro/test/units/routing/endpoints.nodetest.js (renamed from packages/astro/test/units/routing/endpoints.test.js)23
-rw-r--r--packages/astro/test/units/routing/manifest.nodetest.js (renamed from packages/astro/test/units/routing/manifest.test.js)26
-rw-r--r--packages/astro/test/units/routing/route-matching.nodetest.js (renamed from packages/astro/test/units/routing/route-matching.test.js)23
-rw-r--r--packages/astro/test/units/routing/route-sanitization.nodetest.js (renamed from packages/astro/test/units/routing/route-sanitization.test.js)5
-rw-r--r--packages/astro/test/units/routing/trailing-slash.nodetest.js (renamed from packages/astro/test/units/routing/trailing-slash.test.js)9
-rw-r--r--packages/astro/test/units/runtime/astro-global.nodetest.js29
-rw-r--r--packages/astro/test/units/runtime/astro-global.test.js18
-rw-r--r--packages/astro/test/units/vite-plugin-astro-server/controller.nodetest.js (renamed from packages/astro/test/units/vite-plugin-astro-server/controller.test.js)27
-rw-r--r--packages/astro/test/units/vite-plugin-astro-server/request.nodetest.js (renamed from packages/astro/test/units/vite-plugin-astro-server/request.test.js)9
-rw-r--r--packages/astro/test/units/vite-plugin-astro-server/response.nodetest.js (renamed from packages/astro/test/units/vite-plugin-astro-server/response.test.js)7
-rw-r--r--packages/astro/test/units/vite-plugin-astro/compile.nodetest.js (renamed from packages/astro/test/units/vite-plugin-astro/compile.test.js)17
-rw-r--r--packages/astro/test/units/vite-plugin-scanner/scan.nodetest.js (renamed from packages/astro/test/units/vite-plugin-scanner/scan.test.js)75
33 files changed, 847 insertions, 840 deletions
diff --git a/packages/astro/package.json b/packages/astro/package.json
index 15935f59c..b772cd516 100644
--- a/packages/astro/package.json
+++ b/packages/astro/package.json
@@ -107,9 +107,7 @@
"build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" && pnpm run postbuild",
"dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"",
"postbuild": "astro-scripts copy \"src/**/*.astro\" && astro-scripts copy \"src/**/*.wasm\"",
- "test:unit": "mocha --exit --timeout 30000 ./test/units/**/*.test.js --ignore **/*.nodetest.js",
- "test:unit:match": "mocha --exit --timeout 30000 ./test/units/**/*.test.js -g --ignore **/*.nodetest.js",
- "test": "pnpm run test:node && pnpm run test:unit && mocha --exit --timeout 30000 --ignore **/*.nodetest.js --ignore **/lit-element.test.js && mocha --timeout 30000 **/lit-element.test.js --ignore **/*.nodetest.js",
+ "test": "pnpm run test:node && mocha --exit --timeout 30000 --ignore **/*.nodetest.js --ignore **/lit-element.test.js && mocha --timeout 30000 **/lit-element.test.js --ignore **/*.nodetest.js",
"test:match": "mocha --timeout 30000 -g",
"test:e2e": "playwright test",
"test:e2e:match": "playwright test -g",
diff --git a/packages/astro/test/units/app/headers.test.js b/packages/astro/test/units/app/headers.nodetest.js
index d9e5d6f8e..e8ae33f53 100644
--- a/packages/astro/test/units/app/headers.test.js
+++ b/packages/astro/test/units/app/headers.nodetest.js
@@ -1,29 +1,29 @@
-import { expect } from 'chai';
-
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createOutgoingHttpHeaders } from '../../../dist/core/app/createOutgoingHttpHeaders.js';
describe('createOutgoingHttpHeaders', () => {
it('undefined input headers', async () => {
const result = createOutgoingHttpHeaders(undefined);
- expect(result).to.equal(undefined);
+ assert.equal(result, undefined);
});
it('null input headers', async () => {
const result = createOutgoingHttpHeaders(undefined);
- expect(result).to.equal(undefined);
+ assert.equal(result, undefined);
});
it('Empty Headers', async () => {
const headers = new Headers();
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.equal(undefined);
+ assert.equal(result, undefined);
});
it('Headers with single key', async () => {
const headers = new Headers();
headers.append('x-test', 'hello world');
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.deep.equal({ 'x-test': 'hello world' });
+ assert.deepEqual(result, { 'x-test': 'hello world' });
});
it('Headers with multiple keys', async () => {
@@ -31,7 +31,7 @@ describe('createOutgoingHttpHeaders', () => {
headers.append('x-test1', 'hello');
headers.append('x-test2', 'world');
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.deep.equal({ 'x-test1': 'hello', 'x-test2': 'world' });
+ assert.deepEqual(result, { 'x-test1': 'hello', 'x-test2': 'world' });
});
it('Headers with multiple values (not set-cookie)', async () => {
@@ -39,7 +39,7 @@ describe('createOutgoingHttpHeaders', () => {
headers.append('x-test', 'hello');
headers.append('x-test', 'world');
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.deep.equal({ 'x-test': 'hello, world' });
+ assert.deepEqual(result, { 'x-test': 'hello, world' });
});
it('Headers with multiple values (set-cookie special case)', async () => {
@@ -47,7 +47,7 @@ describe('createOutgoingHttpHeaders', () => {
headers.append('set-cookie', 'hello');
headers.append('set-cookie', 'world');
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.deep.equal({ 'set-cookie': ['hello', 'world'] });
+ assert.deepEqual(result, { 'set-cookie': ['hello', 'world'] });
});
it('Headers with multiple values (set-cookie case handling)', async () => {
@@ -55,7 +55,7 @@ describe('createOutgoingHttpHeaders', () => {
headers.append('Set-cookie', 'hello');
headers.append('Set-Cookie', 'world');
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.deep.equal({ 'set-cookie': ['hello', 'world'] });
+ assert.deepEqual(result, { 'set-cookie': ['hello', 'world'] });
});
it('Headers with all use cases', async () => {
@@ -67,7 +67,7 @@ describe('createOutgoingHttpHeaders', () => {
headers.append('Set-cookie', 'hello');
headers.append('Set-Cookie', 'world');
const result = createOutgoingHttpHeaders(headers);
- expect(result).to.deep.equal({
+ assert.deepEqual(result, {
'x-single': 'single',
'x-triple': 'one, two, three',
'set-cookie': ['hello', 'world'],
diff --git a/packages/astro/test/units/assets/remote-pattern.nodetest.js b/packages/astro/test/units/assets/remote-pattern.nodetest.js
new file mode 100644
index 000000000..316b81860
--- /dev/null
+++ b/packages/astro/test/units/assets/remote-pattern.nodetest.js
@@ -0,0 +1,116 @@
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
+import {
+ matchProtocol,
+ matchPort,
+ matchHostname,
+ matchPathname,
+ matchPattern,
+} from '../../../dist/assets/utils/remotePattern.js';
+
+describe('astro/src/assets/utils/remotePattern', () => {
+ const url1 = new URL('https://docs.astro.build/en/getting-started');
+ const url2 = new URL('http://preview.docs.astro.build:8080/');
+ const url3 = new URL('https://astro.build/');
+ const url4 = new URL('https://example.co/');
+
+ describe('remote pattern matchers', () => {
+ it('matches protocol', async () => {
+ // undefined
+ assert.equal(matchProtocol(url1), true);
+
+ // defined, true/false
+ assert.equal(matchProtocol(url1, 'http'), false);
+ assert.equal(matchProtocol(url1, 'https'), true);
+ });
+
+ it('matches port', async () => {
+ // undefined
+ assert.equal(matchPort(url1), true);
+
+ // defined, but port is empty (default port used in URL)
+ assert.equal(matchPort(url1, ''), true);
+
+ // defined and port is custom
+ assert.equal(matchPort(url2, '8080'), true);
+ });
+
+ it('matches hostname (no wildcards)', async () => {
+ // undefined
+ assert.equal(matchHostname(url1), true);
+
+ // defined, true/false
+ assert.equal(matchHostname(url1, 'astro.build'), false);
+ assert.equal(matchHostname(url1, 'docs.astro.build'), true);
+ });
+
+ it('matches hostname (with wildcards)', async () => {
+ // defined, true/false
+ assert.equal(matchHostname(url1, 'docs.astro.build', true), true);
+ assert.equal(matchHostname(url1, '**.astro.build', true), true);
+ assert.equal(matchHostname(url1, '*.astro.build', true), true);
+
+ assert.equal(matchHostname(url2, '*.astro.build', true), false);
+ assert.equal(matchHostname(url2, '**.astro.build', true), true);
+
+ assert.equal(matchHostname(url3, 'astro.build', true), true);
+ assert.equal(matchHostname(url3, '*.astro.build', true), false);
+ assert.equal(matchHostname(url3, '**.astro.build', true), false);
+ });
+
+ it('matches pathname (no wildcards)', async () => {
+ // undefined
+ assert.equal(matchPathname(url1), true);
+
+ // defined, true/false
+ assert.equal(matchPathname(url1, '/'), false);
+ assert.equal(matchPathname(url1, '/en/getting-started'), true);
+ });
+
+ it('matches pathname (with wildcards)', async () => {
+ // defined, true/false
+ assert.equal(matchPathname(url1, '/en/**', true), true);
+ assert.equal(matchPathname(url1, '/en/*', true), true);
+ assert.equal(matchPathname(url1, '/**', true), true);
+
+ assert.equal(matchPathname(url2, '/**', true), false);
+ assert.equal(matchPathname(url2, '/*', true), false);
+ });
+
+ it('matches patterns', async () => {
+ assert.equal(matchPattern(url1, {}), true);
+
+ assert.equal(
+ matchPattern(url1, {
+ protocol: 'https',
+ }),
+ true
+ );
+
+ assert.equal(
+ matchPattern(url1, {
+ protocol: 'https',
+ hostname: '**.astro.build',
+ }),
+ true
+ );
+
+ assert.equal(
+ matchPattern(url1, {
+ protocol: 'https',
+ hostname: '**.astro.build',
+ pathname: '/en/**',
+ }),
+ true
+ );
+
+ assert.equal(
+ matchPattern(url4, {
+ protocol: 'https',
+ hostname: 'example.com',
+ }),
+ false
+ );
+ });
+ });
+});
diff --git a/packages/astro/test/units/assets/remote-pattern.test.js b/packages/astro/test/units/assets/remote-pattern.test.js
deleted file mode 100644
index 62a411e3a..000000000
--- a/packages/astro/test/units/assets/remote-pattern.test.js
+++ /dev/null
@@ -1,111 +0,0 @@
-import { expect } from 'chai';
-import {
- matchProtocol,
- matchPort,
- matchHostname,
- matchPathname,
- matchPattern,
-} from '../../../dist/assets/utils/remotePattern.js';
-
-describe('astro/src/assets/utils/remotePattern', () => {
- const url1 = new URL('https://docs.astro.build/en/getting-started');
- const url2 = new URL('http://preview.docs.astro.build:8080/');
- const url3 = new URL('https://astro.build/');
- const url4 = new URL('https://example.co/');
-
- describe('remote pattern matchers', () => {
- it('matches protocol', async () => {
- // undefined
- expect(matchProtocol(url1)).to.be.true;
-
- // defined, true/false
- expect(matchProtocol(url1, 'http')).to.be.false;
- expect(matchProtocol(url1, 'https')).to.be.true;
- });
-
- it('matches port', async () => {
- // undefined
- expect(matchPort(url1)).to.be.true;
-
- // defined, but port is empty (default port used in URL)
- expect(matchPort(url1, '')).to.be.true;
-
- // defined and port is custom
- expect(matchPort(url2, '8080')).to.be.true;
- });
-
- it('matches hostname (no wildcards)', async () => {
- // undefined
- expect(matchHostname(url1)).to.be.true;
-
- // defined, true/false
- expect(matchHostname(url1, 'astro.build')).to.be.false;
- expect(matchHostname(url1, 'docs.astro.build')).to.be.true;
- });
-
- it('matches hostname (with wildcards)', async () => {
- // defined, true/false
- expect(matchHostname(url1, 'docs.astro.build', true)).to.be.true;
- expect(matchHostname(url1, '**.astro.build', true)).to.be.true;
- expect(matchHostname(url1, '*.astro.build', true)).to.be.true;
-
- expect(matchHostname(url2, '*.astro.build', true)).to.be.false;
- expect(matchHostname(url2, '**.astro.build', true)).to.be.true;
-
- expect(matchHostname(url3, 'astro.build', true)).to.be.true;
- expect(matchHostname(url3, '*.astro.build', true)).to.be.false;
- expect(matchHostname(url3, '**.astro.build', true)).to.be.false;
- });
-
- it('matches pathname (no wildcards)', async () => {
- // undefined
- expect(matchPathname(url1)).to.be.true;
-
- // defined, true/false
- expect(matchPathname(url1, '/')).to.be.false;
- expect(matchPathname(url1, '/en/getting-started')).to.be.true;
- });
-
- it('matches pathname (with wildcards)', async () => {
- // defined, true/false
- expect(matchPathname(url1, '/en/**', true)).to.be.true;
- expect(matchPathname(url1, '/en/*', true)).to.be.true;
- expect(matchPathname(url1, '/**', true)).to.be.true;
-
- expect(matchPathname(url2, '/**', true)).to.be.false;
- expect(matchPathname(url2, '/*', true)).to.be.false;
- });
-
- it('matches patterns', async () => {
- expect(matchPattern(url1, {})).to.be.true;
-
- expect(
- matchPattern(url1, {
- protocol: 'https',
- })
- ).to.be.true;
-
- expect(
- matchPattern(url1, {
- protocol: 'https',
- hostname: '**.astro.build',
- })
- ).to.be.true;
-
- expect(
- matchPattern(url1, {
- protocol: 'https',
- hostname: '**.astro.build',
- pathname: '/en/**',
- })
- ).to.be.true;
-
- expect(
- matchPattern(url4, {
- protocol: 'https',
- hostname: 'example.com',
- })
- ).to.be.false;
- });
- });
-});
diff --git a/packages/astro/test/units/build/static-build.test.js b/packages/astro/test/units/build/static-build.nodetest.js
index 38896c5aa..acc3395df 100644
--- a/packages/astro/test/units/build/static-build.test.js
+++ b/packages/astro/test/units/build/static-build.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { makeAstroPageEntryPointFileName } from '../../../dist/core/build/static-build.js';
describe('astro/src/core/build', () => {
@@ -30,21 +31,21 @@ describe('astro/src/core/build', () => {
const input = '@astro-page:src/pages/index@_@astro';
const output = 'pages/index.astro.mjs';
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output);
+ assert.equal(result, output);
});
it('handles dynamic pages', async () => {
const input = '@astro-page:src/pages/blog/[year]/[...slug]@_@astro';
const output = 'pages/blog/_year_/_---slug_.astro.mjs';
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output);
+ assert.equal(result, output);
});
it('handles node_modules pages', async () => {
const input = '@astro-page:../node_modules/my-dep/injected@_@astro';
const output = 'pages/injected.astro.mjs';
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output);
+ assert.equal(result, output);
});
// Fix #7561
@@ -52,7 +53,7 @@ describe('astro/src/core/build', () => {
const input = '@astro-page:../../packages/demo/[...all]@_@astro';
const output = 'pages/injected-workspace.astro.mjs';
const result = makeAstroPageEntryPointFileName('@astro-page:', input, routes);
- expect(result).to.equal(output);
+ assert.equal(result, output);
});
});
});
diff --git a/packages/astro/test/units/compile/invalid-css.test.js b/packages/astro/test/units/compile/invalid-css.nodetest.js
index 794e335b4..b43fb8ff6 100644
--- a/packages/astro/test/units/compile/invalid-css.test.js
+++ b/packages/astro/test/units/compile/invalid-css.nodetest.js
@@ -1,5 +1,6 @@
import { resolveConfig } from 'vite';
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { compile } from '../../../dist/core/compile/index.js';
import { AggregateError } from '../../../dist/core/errors/index.js';
import { pathToFileURL } from 'node:url';
@@ -35,8 +36,8 @@ describe('astro/src/core/compile', () => {
error = err;
}
- expect(error).to.be.an.instanceOf(AggregateError);
- expect(error.errors[0].message).to.contain('expected ")"');
+ assert.equal(error instanceof AggregateError, true);
+ assert.equal(error.errors[0].message.includes('expected ")"'), true);
});
});
});
diff --git a/packages/astro/test/units/dev/base.test.js b/packages/astro/test/units/dev/base.nodetest.js
index 041d6bcb5..a3006163b 100644
--- a/packages/astro/test/units/dev/base.test.js
+++ b/packages/astro/test/units/dev/base.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js';
@@ -31,7 +32,7 @@ describe('base configuration', () => {
});
container.handle(req, res);
await done;
- expect(res.statusCode).to.equal(404);
+ assert.equal(res.statusCode, 404);
}
);
});
@@ -60,7 +61,7 @@ describe('base configuration', () => {
});
container.handle(req, res);
await done;
- expect(res.statusCode).to.equal(200);
+ assert.equal(res.statusCode, 200);
}
);
});
@@ -91,7 +92,7 @@ describe('base configuration', () => {
});
container.handle(req, res);
await done;
- expect(res.statusCode).to.equal(404);
+ assert.equal(res.statusCode, 404);
}
);
});
@@ -120,7 +121,7 @@ describe('base configuration', () => {
});
container.handle(req, res);
await done;
- expect(res.statusCode).to.equal(200);
+ assert.equal(res.statusCode, 200);
}
);
});
diff --git a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js b/packages/astro/test/units/dev/collections-mixed-content-errors.nodetest.js
index 9cad4f5e8..26ea1334d 100644
--- a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js
+++ b/packages/astro/test/units/dev/collections-mixed-content-errors.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
import _sync from '../../../dist/core/sync/index.js';
import { createFsWithFallback } from '../test-utils.js';
@@ -35,7 +36,7 @@ name: Ben
root
);
- expect(await sync({ fs })).to.equal(1);
+ assert.equal(await sync({ fs }), 1);
});
it('raises "mixed content" error when data in content collection', async () => {
@@ -63,7 +64,7 @@ title: Post
root
);
- expect(await sync({ fs })).to.equal(1);
+ assert.equal(await sync({ fs }), 1);
});
it('raises error when data collection configured as content collection', async () => {
@@ -86,7 +87,7 @@ title: Post
root
);
- expect(await sync({ fs })).to.equal(1);
+ assert.equal(await sync({ fs }), 1);
});
it('does not raise error for empty collection with config', async () => {
@@ -111,7 +112,7 @@ title: Post
try {
const res = await sync({ fs });
- expect(res).to.equal(0);
+ assert.equal(res, 0);
} catch (e) {
expect.fail(0, 1, `Did not expect sync to throw: ${e.message}`);
}
diff --git a/packages/astro/test/units/dev/collections-renderentry.test.js b/packages/astro/test/units/dev/collections-renderentry.nodetest.js
index 873bb9164..cf3674027 100644
--- a/packages/astro/test/units/dev/collections-renderentry.test.js
+++ b/packages/astro/test/units/dev/collections-renderentry.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import * as cheerio from 'cheerio';
import os from 'node:os';
import { fileURLToPath } from 'node:url';
@@ -8,7 +9,7 @@ import { createFsWithFallback, createRequestAndResponse, runInContainer } from '
const root = new URL('../../fixtures/content/', import.meta.url);
-const describe = os.platform() === 'win32' ? global.describe.skip : global.describe;
+const _describe = os.platform() === 'win32' ? describe.skip : describe;
/** @type {typeof runInContainer} */
async function runInContainerWithContentListeners(params, callback) {
@@ -18,7 +19,7 @@ async function runInContainerWithContentListeners(params, callback) {
});
}
-describe('Content Collections - render()', () => {
+_describe('Content Collections - render()', () => {
it('can be called in a page component', async () => {
const fs = createFsWithFallback(
{
@@ -72,10 +73,10 @@ describe('Content Collections - render()', () => {
const $ = cheerio.load(html);
// Rendered the content
- expect($('ul li')).to.have.a.lengthOf(3);
+ assert.equal($('ul li').length, 3);
// Rendered the styles
- expect($('style')).to.have.a.lengthOf(1);
+ assert.equal($('style').length, 1);
}
);
});
@@ -144,10 +145,10 @@ description: Astro is launching this week!
const $ = cheerio.load(html);
// Rendered the content
- expect($('ul li')).to.have.a.lengthOf(3);
+ assert.equal($('ul li').length, 3);
// Rendered the styles
- expect($('style')).to.have.a.lengthOf(1);
+ assert.equal($('style').length, 1);
}
);
});
@@ -214,10 +215,10 @@ description: Astro is launching this week!
const $ = cheerio.load(html);
// Rendered the content
- expect($('ul li')).to.have.a.lengthOf(3);
+ assert.equal($('ul li').length, 3);
// Rendered the styles
- expect($('style')).to.have.a.lengthOf(1);
+ assert.equal($('style').length, 1);
}
);
});
@@ -283,10 +284,10 @@ description: Astro is launching this week!
const $ = cheerio.load(html);
// Rendered the content
- expect($('ul li')).to.have.a.lengthOf(3);
+ assert.equal($('ul li').length, 3);
// Rendered the styles
- expect($('style')).to.have.a.lengthOf(1);
+ assert.equal($('style').length, 1);
}
);
});
diff --git a/packages/astro/test/units/dev/dev.test.js b/packages/astro/test/units/dev/dev.nodetest.js
index 9b713d62a..b89e18feb 100644
--- a/packages/astro/test/units/dev/dev.test.js
+++ b/packages/astro/test/units/dev/dev.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import * as cheerio from 'cheerio';
import { fileURLToPath } from 'node:url';
import {
@@ -37,8 +38,8 @@ describe('dev container', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect(res.statusCode).to.equal(200);
- expect($('h1')).to.have.a.lengthOf(1);
+ assert.equal(res.statusCode, 200);
+ assert.equal($('h1').length, 1);
});
});
@@ -72,7 +73,7 @@ describe('dev container', () => {
container.handle(r.req, r.res);
let html = await r.text();
let $ = cheerio.load(html);
- expect($('body.one')).to.have.a.lengthOf(1);
+ assert.equal($('body.one').length, 1);
fs.writeFileFromRootSync(
'/src/components/Header.astro',
@@ -106,8 +107,8 @@ describe('dev container', () => {
container.handle(r.req, r.res);
html = await r.text();
$ = cheerio.load(html);
- expect($('body.one')).to.have.a.lengthOf(0);
- expect($('body.two')).to.have.a.lengthOf(1);
+ assert.equal($('body.one').length, 0);
+ assert.equal($('body.two').length, 1);
});
});
@@ -148,7 +149,7 @@ describe('dev container', () => {
});
container.handle(r.req, r.res);
await r.done;
- expect(r.res.statusCode).to.equal(200);
+ assert.equal(r.res.statusCode, 200);
// Try with the injected route
r = createRequestAndResponse({
@@ -157,7 +158,7 @@ describe('dev container', () => {
});
container.handle(r.req, r.res);
await r.done;
- expect(r.res.statusCode).to.equal(200);
+ assert.equal(r.res.statusCode, 200);
}
);
});
@@ -199,8 +200,8 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
const doc = await r.text();
- expect(doc).to.match(/Regular page/);
- expect(r.res.statusCode).to.equal(200);
+ assert.equal(/Regular page/.test(doc), true);
+ assert.equal(r.res.statusCode, 200);
}
{
// `/404` serves the custom 404 page as expected.
@@ -208,8 +209,8 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
const doc = await r.text();
- expect(doc).to.match(/Custom 404/);
- expect(r.res.statusCode).to.equal(404);
+ assert.equal(/Custom 404/.test(doc), true);
+ assert.equal(r.res.statusCode, 404);
}
{
// A non-existent page also serves the custom 404 page.
@@ -217,8 +218,8 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
const doc = await r.text();
- expect(doc).to.match(/Custom 404/);
- expect(r.res.statusCode).to.equal(404);
+ assert.equal(/Custom 404/.test(doc), true);
+ assert.equal(r.res.statusCode, 404);
}
}
);
@@ -242,7 +243,7 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
- expect(r.res.statusCode).to.equal(200);
+ assert.equal(r.res.statusCode, 200);
// Next try the root path
r = createRequestAndResponse({
@@ -253,7 +254,7 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
- expect(r.res.statusCode).to.equal(404);
+ assert.equal(r.res.statusCode, 404);
}
);
});
@@ -269,7 +270,7 @@ describe('dev container', () => {
container.handle(r.req, r.res);
await r.done;
- expect(r.res.statusCode).to.equal(200);
+ assert.equal(r.res.statusCode, 200);
});
});
});
diff --git a/packages/astro/test/units/dev/head-injection.test.js b/packages/astro/test/units/dev/head-injection.nodetest.js
index 9b38feae6..837fc45b9 100644
--- a/packages/astro/test/units/dev/head-injection.test.js
+++ b/packages/astro/test/units/dev/head-injection.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import * as cheerio from 'cheerio';
import { fileURLToPath } from 'node:url';
import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js';
@@ -79,8 +80,8 @@ describe('head injection', () => {
const html = await text();
const $ = cheerio.load(html);
- expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1);
- expect($('#other')).to.have.a.lengthOf(1);
+ assert.equal($('link[rel=stylesheet][href="/some/fake/styles.css"]').length, 1);
+ assert.equal($('#other').length, 1);
}
);
});
@@ -179,11 +180,12 @@ describe('head injection', () => {
const html = await text();
const $ = cheerio.load(html);
- expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(
+ assert.equal(
+ $('link[rel=stylesheet][href="/some/fake/styles.css"]').length,
1,
'found inner link'
);
- expect($('#other')).to.have.a.lengthOf(1, 'Found the #other div');
+ assert.equal($('#other').length, 1, 'Found the #other div');
}
);
});
diff --git a/packages/astro/test/units/dev/hydration.test.js b/packages/astro/test/units/dev/hydration.nodetest.js
index ae4cb2d99..4507f0c84 100644
--- a/packages/astro/test/units/dev/hydration.test.js
+++ b/packages/astro/test/units/dev/hydration.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js';
@@ -41,7 +42,8 @@ describe('hydration', () => {
});
container.handle(req, res);
await done;
- expect(res.statusCode).to.equal(
+ assert.equal(
+ res.statusCode,
200,
"We get a 200 because the error occurs in the template, but we didn't crash!"
);
diff --git a/packages/astro/test/units/dev/restart.test.js b/packages/astro/test/units/dev/restart.nodetest.js
index 1b00d5c6a..0fad93de4 100644
--- a/packages/astro/test/units/dev/restart.test.js
+++ b/packages/astro/test/units/dev/restart.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import * as cheerio from 'cheerio';
import { fileURLToPath } from 'node:url';
@@ -46,8 +47,8 @@ describe('dev container restarts', () => {
restart.container.handle(r.req, r.res);
let html = await r.text();
const $ = cheerio.load(html);
- expect(r.res.statusCode).to.equal(200);
- expect($('h1')).to.have.a.lengthOf(1);
+ assert.equal(r.res.statusCode, 200);
+ assert.equal($('h1').length, 1);
// Create an error
let restartComplete = restart.restarted();
@@ -61,7 +62,7 @@ describe('dev container restarts', () => {
// Wait for the restart to finish
let hmrError = await restartComplete;
- expect(hmrError).to.not.be.a('undefined');
+ assert.notEqual(typeof hmrError, 'undefined');
// Do it a second time to make sure we are still watching
@@ -75,7 +76,7 @@ describe('dev container restarts', () => {
);
hmrError = await restartComplete;
- expect(hmrError).to.not.be.a('undefined');
+ assert.notEqual(typeof hmrError, 'undefined');
} finally {
await restart.container.close();
}
@@ -102,7 +103,7 @@ describe('dev container restarts', () => {
inlineConfig: { root: fileURLToPath(root), logLevel: 'silent' },
});
await startContainer(restart.container);
- expect(isStarted(restart.container)).to.equal(true);
+ assert.equal(isStarted(restart.container), true);
try {
// Trigger a change
@@ -110,7 +111,7 @@ describe('dev container restarts', () => {
triggerFSEvent(restart.container, fs, '/astro.config.mjs', 'change');
await restartComplete;
- expect(isStarted(restart.container)).to.equal(true);
+ assert.equal(isStarted(restart.container), true);
} finally {
await restart.container.close();
}
@@ -131,7 +132,7 @@ describe('dev container restarts', () => {
inlineConfig: { root: fileURLToPath(root), logLevel: 'silent' },
});
await startContainer(restart.container);
- expect(isStarted(restart.container)).to.equal(true);
+ assert.equal(isStarted(restart.container), true);
try {
// Trigger a change
@@ -139,7 +140,7 @@ describe('dev container restarts', () => {
triggerFSEvent(restart.container, fs, '/astro.config.ts', 'change');
await restartComplete;
- expect(isStarted(restart.container)).to.equal(true);
+ assert.equal(isStarted(restart.container), true);
} finally {
await restart.container.close();
}
@@ -158,7 +159,7 @@ describe('dev container restarts', () => {
inlineConfig: { root: fileURLToPath(root), logLevel: 'silent' },
});
await startContainer(restart.container);
- expect(isStarted(restart.container)).to.equal(true);
+ assert.equal(isStarted(restart.container), true);
try {
let restartComplete = restart.restarted();
@@ -183,7 +184,7 @@ describe('dev container restarts', () => {
inlineConfig: { root: fileURLToPath(root), logLevel: 'silent' },
});
await startContainer(restart.container);
- expect(isStarted(restart.container)).to.equal(true);
+ assert.equal(isStarted(restart.container), true);
try {
let restartComplete = restart.restarted();
diff --git a/packages/astro/test/units/dev/styles.test.js b/packages/astro/test/units/dev/styles.nodetest.js
index 526b8fbef..a1ab6b942 100644
--- a/packages/astro/test/units/dev/styles.test.js
+++ b/packages/astro/test/units/dev/styles.nodetest.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import { describe, it, before } from 'node:test';
+import * as assert from 'node:assert/strict';
import { getStylesForURL } from '../../../dist/vite-plugin-astro-server/css.js';
import { viteID } from '../../../dist/core/util.js';
@@ -76,6 +76,6 @@ describe('Crawling graph for CSS', () => {
// In dev mode, HMR modules tracked are added to importedModules. We use `importers`
// to verify that they are true importers.
const res = await getStylesForURL(new URL('./src/pages/index.astro', root), loader);
- expect(res.styles.length).to.equal(1);
+ assert.equal(res.styles.length, 1);
});
});
diff --git a/packages/astro/test/units/i18n/astro_i18n.test.js b/packages/astro/test/units/i18n/astro_i18n.nodetest.js
index 1e0d0475c..a568ce6bc 100644
--- a/packages/astro/test/units/i18n/astro_i18n.test.js
+++ b/packages/astro/test/units/i18n/astro_i18n.nodetest.js
@@ -5,8 +5,11 @@ import {
getLocaleAbsoluteUrlList,
} from '../../../dist/i18n/index.js';
import { parseLocale } from '../../../dist/core/render/context.js';
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { validateConfig } from '../../../dist/core/config/config.js';
+import { AstroError } from '#astro/core/errors/index';
+import { MissingLocale } from '#astro/core/errors/errors-data';
describe('getLocaleRelativeUrl', () => {
it('should correctly return the URL with the base', () => {
@@ -33,74 +36,59 @@ describe('getLocaleRelativeUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
trailingSlash: 'always',
format: 'directory',
...config.experimental.i18n,
- })
- ).to.eq('/blog/');
- expect(
+ }),
+ '/blog/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/es/');
-
- expect(
- getLocaleRelativeUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'directory',
- })
- ).to.throw;
+ }),
+ '/blog/es/'
+ );
// file format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/');
- expect(
+ }),
+ '/blog/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/es/');
-
- expect(
- getLocaleRelativeUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'file',
- })
- ).to.throw;
+ }),
+ '/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'it-VA',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/italiano/');
+ }),
+ '/blog/italiano/'
+ );
});
it('should correctly return the URL without base', () => {
@@ -117,24 +105,26 @@ describe('getLocaleRelativeUrl', () => {
},
};
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/');
- expect(
+ }),
+ '/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/es/');
+ }),
+ '/es/'
+ );
});
it('should correctly handle the trailing slash', () => {
@@ -156,66 +146,72 @@ describe('getLocaleRelativeUrl', () => {
},
};
// directory format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog',
...config.i18n,
trailingSlash: 'never',
format: 'directory',
- })
- ).to.eq('/blog');
- expect(
+ }),
+ '/blog'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/es/');
+ }),
+ '/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'it-VA',
base: '/blog/',
...config.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/italiano/');
+ }),
+ '/blog/italiano/'
+ );
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
...config.i18n,
trailingSlash: 'ignore',
format: 'directory',
- })
- ).to.eq('/blog/');
+ }),
+ '/blog/'
+ );
// directory file
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog',
...config.i18n,
trailingSlash: 'never',
format: 'file',
- })
- ).to.eq('/blog');
- expect(
+ }),
+ '/blog'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/es/');
+ }),
+ '/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
// ignore + file => no trailing slash
@@ -223,8 +219,9 @@ describe('getLocaleRelativeUrl', () => {
...config.i18n,
trailingSlash: 'ignore',
format: 'file',
- })
- ).to.eq('/blog');
+ }),
+ '/blog'
+ );
});
it('should normalize locales by default', () => {
@@ -242,17 +239,18 @@ describe('getLocaleRelativeUrl', () => {
},
};
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en_US',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/en-us/');
+ }),
+ '/blog/en-us/'
+ );
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en_US',
base: '/blog/',
@@ -260,18 +258,20 @@ describe('getLocaleRelativeUrl', () => {
trailingSlash: 'always',
format: 'directory',
normalizeLocale: false,
- })
- ).to.eq('/blog/en_US/');
+ }),
+ '/blog/en_US/'
+ );
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en_AU',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/en-au/');
+ }),
+ '/blog/en-au/'
+ );
});
it('should return the default locale when routing strategy is [pathname-prefix-always]', () => {
@@ -291,64 +291,48 @@ describe('getLocaleRelativeUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
trailingSlash: 'always',
format: 'directory',
...config.experimental.i18n,
- })
- ).to.eq('/blog/en/');
- expect(
+ }),
+ '/blog/en/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/es/');
-
- expect(
- getLocaleRelativeUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'directory',
- })
- ).to.throw;
+ }),
+ '/blog/es/'
+ );
// file format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/en/');
- expect(
+ }),
+ '/blog/en/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/es/');
-
- expect(
- getLocaleRelativeUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'file',
- })
- ).to.throw;
+ }),
+ '/blog/es/'
+ );
});
it('should return the default locale when routing strategy is [pathname-prefix-always-no-redirect]', () => {
@@ -368,64 +352,48 @@ describe('getLocaleRelativeUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
trailingSlash: 'always',
format: 'directory',
...config.experimental.i18n,
- })
- ).to.eq('/blog/en/');
- expect(
+ }),
+ '/blog/en/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/es/');
-
- expect(
- getLocaleRelativeUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'directory',
- })
- ).to.throw;
+ }),
+ '/blog/es/'
+ );
// file format
- expect(
+ assert.equal(
getLocaleRelativeUrl({
locale: 'en',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/en/');
- expect(
+ }),
+ '/blog/en/'
+ );
+ assert.equal(
getLocaleRelativeUrl({
locale: 'es',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('/blog/es/');
-
- expect(
- getLocaleRelativeUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'file',
- })
- ).to.throw;
+ }),
+ '/blog/es/'
+ );
});
});
@@ -452,15 +420,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog',
...config.experimental.i18n,
trailingSlash: 'never',
format: 'directory',
- })
- ).to.have.members(['/blog', '/blog/en-us', '/blog/es', '/blog/italiano']);
+ }),
+ ['/blog', '/blog/en-us', '/blog/es', '/blog/italiano']
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: always]', () => {
@@ -485,15 +454,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.have.members(['/blog/', '/blog/en-us/', '/blog/es/', '/blog/italiano/']);
+ }),
+ ['/blog/', '/blog/en-us/', '/blog/es/', '/blog/italiano/']
+ );
});
it('should retrieve the correct list of base URL with locales [format: file, trailingSlash: always]', () => {
@@ -510,15 +480,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'file',
- })
- ).to.have.members(['/blog/', '/blog/en-us/', '/blog/es/']);
+ }),
+ ['/blog/', '/blog/en-us/', '/blog/es/']
+ );
});
it('should retrieve the correct list of base URL with locales [format: file, trailingSlash: never]', () => {
@@ -535,15 +506,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog',
...config.experimental.i18n,
trailingSlash: 'never',
format: 'file',
- })
- ).to.have.members(['/blog', '/blog/en-us', '/blog/es']);
+ }),
+ ['/blog', '/blog/en-us', '/blog/es']
+ );
});
it('should retrieve the correct list of base URL with locales [format: file, trailingSlash: ignore]', () => {
@@ -560,15 +532,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog',
...config.experimental.i18n,
trailingSlash: 'ignore',
format: 'file',
- })
- ).to.have.members(['/blog', '/blog/en-us', '/blog/es']);
+ }),
+ ['/blog', '/blog/en-us', '/blog/es']
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: ignore]', () => {
@@ -585,15 +558,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'ignore',
format: 'directory',
- })
- ).to.have.members(['/blog/', '/blog/en-us/', '/blog/es/']);
+ }),
+ ['/blog/', '/blog/en-us/', '/blog/es/']
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: never, routingStategy: pathname-prefix-always]', () => {
@@ -611,15 +585,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog',
...config.experimental.i18n,
trailingSlash: 'never',
format: 'directory',
- })
- ).to.have.members(['/blog/en', '/blog/en-us', '/blog/es']);
+ }),
+ ['/blog/en', '/blog/en-us', '/blog/es']
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: never, routingStategy: pathname-prefix-always-no-redirect]', () => {
@@ -637,15 +612,16 @@ describe('getLocaleRelativeUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleRelativeUrlList({
locale: 'en',
base: '/blog',
...config.experimental.i18n,
trailingSlash: 'never',
format: 'directory',
- })
- ).to.have.members(['/blog/en', '/blog/en-us', '/blog/es']);
+ }),
+ ['/blog/en', '/blog/en-us', '/blog/es']
+ );
});
});
@@ -677,7 +653,7 @@ describe('getLocaleAbsoluteUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -685,9 +661,10 @@ describe('getLocaleAbsoluteUrl', () => {
format: 'directory',
site: 'https://example.com',
...config.i18n,
- })
- ).to.eq('https://example.com/blog/');
- expect(
+ }),
+ 'https://example.com/blog/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -695,10 +672,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -707,22 +685,29 @@ describe('getLocaleAbsoluteUrl', () => {
format: 'directory',
site: 'https://example.com',
isBuild: true,
+ }),
+ 'https://es.example.com/blog/'
+ );
+
+ assert.throws(
+ () =>
+ getLocaleAbsoluteUrl({
+ locale: 'ff',
+ base: '/blog/',
+ ...config.i18n,
+ trailingSlash: 'always',
+ format: 'directory',
+ site: 'https://example.com',
+ }),
+
+ new AstroError({
+ ...MissingLocale,
+ message: MissingLocale.message('ff'),
})
- ).to.eq('https://es.example.com/blog/');
-
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.i18n,
- trailingSlash: 'always',
- format: 'directory',
- site: 'https://example.com',
- })
- ).to.throw;
+ );
// file format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -730,9 +715,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/');
- expect(
+ }),
+ 'https://example.com/blog/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -740,20 +726,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.i18n,
- trailingSlash: 'always',
- format: 'file',
- site: 'https://example.com',
- })
- ).to.throw;
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'it-VA',
base: '/blog/',
@@ -761,21 +738,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/italiano/');
+ }),
+ 'https://example.com/blog/italiano/'
+ );
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.i18n,
- trailingSlash: 'always',
- format: 'file',
- site: 'https://example.com',
- })
- ).to.throw;
-
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -784,10 +751,11 @@ describe('getLocaleAbsoluteUrl', () => {
format: 'file',
site: 'https://example.com',
isBuild: true,
- })
- ).to.eq('https://es.example.com/blog/');
+ }),
+ 'https://es.example.com/blog/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -798,11 +766,12 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
path: 'first-post',
isBuild: true,
- })
- ).to.eq('https://es.example.com/blog/some-name/first-post/');
+ }),
+ 'https://es.example.com/blog/some-name/first-post/'
+ );
// en isn't mapped to a domain
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -813,8 +782,9 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
path: 'first-post',
isBuild: true,
- })
- ).to.eq('https://example.com/blog/some-name/first-post/');
+ }),
+ 'https://example.com/blog/some-name/first-post/'
+ );
});
});
describe('with [prefix-always]', () => {
@@ -838,7 +808,7 @@ describe('getLocaleAbsoluteUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -846,10 +816,11 @@ describe('getLocaleAbsoluteUrl', () => {
format: 'directory',
site: 'https://example.com',
...config.experimental.i18n,
- })
- ).to.eq('https://example.com/blog/en/');
+ }),
+ 'https://example.com/blog/en/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -857,22 +828,12 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
-
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'directory',
- site: 'https://example.com',
- })
- ).to.throw;
+ }),
+ 'https://example.com/blog/es/'
+ );
// file format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -880,9 +841,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/en/');
- expect(
+ }),
+ 'https://example.com/blog/en/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -890,21 +852,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
-
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- trailingSlash: 'always',
- format: 'file',
- site: 'https://example.com',
- })
- ).to.throw;
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -913,10 +865,11 @@ describe('getLocaleAbsoluteUrl', () => {
format: 'file',
site: 'https://example.com',
isBuild: true,
- })
- ).to.eq('https://es.example.com/blog/');
+ }),
+ 'https://es.example.com/blog/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -927,8 +880,9 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
path: 'first-post',
isBuild: true,
- })
- ).to.eq('https://es.example.com/blog/some-name/first-post/');
+ }),
+ 'https://es.example.com/blog/some-name/first-post/'
+ );
});
it('should correctly return the URL without base', () => {
/**
@@ -945,7 +899,7 @@ describe('getLocaleAbsoluteUrl', () => {
},
};
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/',
@@ -953,9 +907,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/en/');
- expect(
+ }),
+ 'https://example.com/en/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/',
@@ -963,8 +918,9 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/es/');
+ }),
+ 'https://example.com/es/'
+ );
});
it('should correctly handle the trailing slash', () => {
@@ -980,7 +936,7 @@ describe('getLocaleAbsoluteUrl', () => {
},
};
// directory format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog',
@@ -988,9 +944,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'never',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/en');
- expect(
+ }),
+ 'https://example.com/blog/en'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -998,10 +955,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -1009,11 +967,12 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'ignore',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/en/');
+ }),
+ 'https://example.com/blog/en/'
+ );
// directory file
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog',
@@ -1021,9 +980,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'never',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/en');
- expect(
+ }),
+ 'https://example.com/blog/en'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1031,10 +991,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
// ignore + file => no trailing slash
@@ -1043,8 +1004,9 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'ignore',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/en');
+ }),
+ 'https://example.com/blog/en'
+ );
});
it('should normalize locales', () => {
@@ -1063,27 +1025,29 @@ describe('getLocaleAbsoluteUrl', () => {
},
};
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en_US',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/en-us/');
+ }),
+ '/blog/en-us/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en_AU',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/en-au/');
+ }),
+ '/blog/en-au/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en_US',
base: '/blog/',
@@ -1091,8 +1055,9 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
normalizeLocale: true,
- })
- ).to.eq('/blog/en-us/');
+ }),
+ '/blog/en-us/'
+ );
});
it('should return the default locale when routing strategy is [pathname-prefix-always]', () => {
@@ -1112,7 +1077,7 @@ describe('getLocaleAbsoluteUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -1120,9 +1085,10 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
format: 'directory',
...config.experimental.i18n,
- })
- ).to.eq('https://example.com/blog/en/');
- expect(
+ }),
+ 'https://example.com/blog/en/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1130,22 +1096,12 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('https://example.com/blog/es/');
-
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- site: 'https://example.com',
- trailingSlash: 'always',
- format: 'directory',
- })
- ).to.throw;
+ }),
+ 'https://example.com/blog/es/'
+ );
// file format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -1153,9 +1109,10 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('https://example.com/blog/en/');
- expect(
+ }),
+ 'https://example.com/blog/en/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1163,19 +1120,9 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('https://example.com/blog/es/');
-
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- site: 'https://example.com',
- trailingSlash: 'always',
- format: 'file',
- })
- ).to.throw;
+ }),
+ 'https://example.com/blog/es/'
+ );
});
it('should return the default locale when routing strategy is [pathname-prefix-always-no-redirect]', () => {
@@ -1195,7 +1142,7 @@ describe('getLocaleAbsoluteUrl', () => {
};
// directory format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -1203,9 +1150,10 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
format: 'directory',
...config.experimental.i18n,
- })
- ).to.eq('https://example.com/blog/en/');
- expect(
+ }),
+ 'https://example.com/blog/en/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1213,10 +1161,12 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ console.log(
+ 'ASDF;JKDFAS;JKLADF;SKLJA;FDJKLS;JKLADFSJKLFDAS;LJKFDAS;JLKAFDSJLFDKS',
getLocaleAbsoluteUrl({
locale: 'en_US',
base: '/blog/',
@@ -1225,10 +1175,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
})
- ).to.throw;
+ );
// file format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -1236,9 +1186,10 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('https://example.com/blog/en/');
- expect(
+ }),
+ 'https://example.com/blog/en/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1246,19 +1197,9 @@ describe('getLocaleAbsoluteUrl', () => {
site: 'https://example.com',
trailingSlash: 'always',
format: 'file',
- })
- ).to.eq('https://example.com/blog/es/');
-
- expect(
- getLocaleAbsoluteUrl({
- locale: 'en_US',
- base: '/blog/',
- ...config.experimental.i18n,
- site: 'https://example.com',
- trailingSlash: 'always',
- format: 'file',
- })
- ).to.throw;
+ }),
+ 'https://example.com/blog/es/'
+ );
});
it('should correctly return the URL without base', () => {
/**
@@ -1282,7 +1223,7 @@ describe('getLocaleAbsoluteUrl', () => {
},
};
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/',
@@ -1290,9 +1231,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/');
- expect(
+ }),
+ 'https://example.com/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/',
@@ -1300,9 +1242,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/es/');
- expect(
+ }),
+ 'https://example.com/es/'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'it-VA',
base: '/',
@@ -1310,8 +1253,9 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/italiano/');
+ }),
+ 'https://example.com/italiano/'
+ );
});
it('should correctly handle the trailing slash', () => {
@@ -1329,7 +1273,7 @@ describe('getLocaleAbsoluteUrl', () => {
},
};
// directory format
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog',
@@ -1337,9 +1281,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'never',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog');
- expect(
+ }),
+ 'https://example.com/blog'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1347,10 +1292,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog/',
@@ -1358,11 +1304,12 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'ignore',
format: 'directory',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/');
+ }),
+ 'https://example.com/blog/'
+ );
// directory file
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
base: '/blog',
@@ -1370,9 +1317,10 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'never',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog');
- expect(
+ }),
+ 'https://example.com/blog'
+ );
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'es',
base: '/blog/',
@@ -1380,10 +1328,11 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog/es/');
+ }),
+ 'https://example.com/blog/es/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en',
// ignore + file => no trailing slash
@@ -1392,8 +1341,9 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'ignore',
format: 'file',
site: 'https://example.com',
- })
- ).to.eq('https://example.com/blog');
+ }),
+ 'https://example.com/blog'
+ );
});
it('should normalize locales', () => {
@@ -1412,27 +1362,29 @@ describe('getLocaleAbsoluteUrl', () => {
},
};
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en_US',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/en-us/');
+ }),
+ '/blog/en-us/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en_AU',
base: '/blog/',
...config.experimental.i18n,
trailingSlash: 'always',
format: 'directory',
- })
- ).to.eq('/blog/en-au/');
+ }),
+ '/blog/en-au/'
+ );
- expect(
+ assert.equal(
getLocaleAbsoluteUrl({
locale: 'en_US',
base: '/blog/',
@@ -1440,8 +1392,9 @@ describe('getLocaleAbsoluteUrl', () => {
trailingSlash: 'always',
format: 'directory',
normalizeLocale: true,
- })
- ).to.eq('/blog/en-us/');
+ }),
+ '/blog/en-us/'
+ );
});
});
});
@@ -1474,19 +1427,20 @@ describe('getLocaleAbsoluteUrlList', () => {
process.cwd()
);
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
...config,
...config.i18n,
isBuild: true,
- })
- ).to.have.members([
- 'https://example.com/blog',
- 'https://example.com/blog/en-us',
- 'https://example.com/blog/es',
- 'https://example.com/blog/italiano',
- ]);
+ }),
+ [
+ 'https://example.com/blog',
+ 'https://example.com/blog/en-us',
+ 'https://example.com/blog/es',
+ 'https://example.com/blog/italiano',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: always]', async () => {
@@ -1508,17 +1462,18 @@ describe('getLocaleAbsoluteUrlList', () => {
process.cwd()
);
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
...config,
...config.i18n,
- })
- ).to.have.members([
- 'https://example.com/blog/',
- 'https://example.com/blog/en-us/',
- 'https://example.com/blog/es/',
- ]);
+ }),
+ [
+ 'https://example.com/blog/',
+ 'https://example.com/blog/en-us/',
+ 'https://example.com/blog/es/',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales and path [format: directory, trailingSlash: always]', async () => {
@@ -1542,18 +1497,19 @@ describe('getLocaleAbsoluteUrlList', () => {
process.cwd()
);
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
path: 'download',
...config,
...config.i18n,
- })
- ).to.have.members([
- 'https://example.com/en/download/',
- 'https://example.com/en-us/download/',
- 'https://example.com/es/download/',
- ]);
+ }),
+ [
+ 'https://example.com/en/download/',
+ 'https://example.com/en-us/download/',
+ 'https://example.com/es/download/',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales and path [format: directory, trailingSlash: always, domains]', async () => {
@@ -1580,19 +1536,20 @@ describe('getLocaleAbsoluteUrlList', () => {
process.cwd()
);
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
path: 'download',
...config,
...config.i18n,
isBuild: true,
- })
- ).to.have.members([
- 'https://example.com/en/download/',
- 'https://example.com/en-us/download/',
- 'https://es.example.com/download/',
- ]);
+ }),
+ [
+ 'https://example.com/en/download/',
+ 'https://example.com/en-us/download/',
+ 'https://es.example.com/download/',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales [format: file, trailingSlash: always]', () => {
@@ -1617,7 +1574,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
base: '/blog/',
@@ -1625,13 +1582,14 @@ describe('getLocaleAbsoluteUrlList', () => {
trailingSlash: 'always',
format: 'file',
site: 'https://example.com',
- })
- ).to.have.members([
- 'https://example.com/blog/',
- 'https://example.com/blog/en-us/',
- 'https://example.com/blog/es/',
- 'https://example.com/blog/italiano/',
- ]);
+ }),
+ [
+ 'https://example.com/blog/',
+ 'https://example.com/blog/en-us/',
+ 'https://example.com/blog/es/',
+ 'https://example.com/blog/italiano/',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales [format: file, trailingSlash: never]', () => {
@@ -1648,7 +1606,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
base: '/blog',
@@ -1656,12 +1614,9 @@ describe('getLocaleAbsoluteUrlList', () => {
trailingSlash: 'never',
format: 'file',
site: 'https://example.com',
- })
- ).to.have.members([
- 'https://example.com/blog',
- 'https://example.com/blog/en-us',
- 'https://example.com/blog/es',
- ]);
+ }),
+ ['https://example.com/blog', 'https://example.com/blog/en-us', 'https://example.com/blog/es']
+ );
});
it('should retrieve the correct list of base URL with locales [format: file, trailingSlash: ignore]', () => {
@@ -1678,7 +1633,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
base: '/blog',
@@ -1686,12 +1641,9 @@ describe('getLocaleAbsoluteUrlList', () => {
trailingSlash: 'ignore',
format: 'file',
site: 'https://example.com',
- })
- ).to.have.members([
- 'https://example.com/blog',
- 'https://example.com/blog/en-us',
- 'https://example.com/blog/es',
- ]);
+ }),
+ ['https://example.com/blog', 'https://example.com/blog/en-us', 'https://example.com/blog/es']
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: ignore]', () => {
@@ -1708,7 +1660,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
base: '/blog/',
@@ -1716,12 +1668,13 @@ describe('getLocaleAbsoluteUrlList', () => {
trailingSlash: 'ignore',
format: 'directory',
site: 'https://example.com',
- })
- ).to.have.members([
- 'https://example.com/blog/',
- 'https://example.com/blog/en-us/',
- 'https://example.com/blog/es/',
- ]);
+ }),
+ [
+ 'https://example.com/blog/',
+ 'https://example.com/blog/en-us/',
+ 'https://example.com/blog/es/',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: ignore, routingStategy: pathname-prefix-always]', () => {
@@ -1739,7 +1692,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
base: '/blog/',
@@ -1747,12 +1700,13 @@ describe('getLocaleAbsoluteUrlList', () => {
trailingSlash: 'ignore',
format: 'directory',
site: 'https://example.com',
- })
- ).to.have.members([
- 'https://example.com/blog/en/',
- 'https://example.com/blog/en-us/',
- 'https://example.com/blog/es/',
- ]);
+ }),
+ [
+ 'https://example.com/blog/en/',
+ 'https://example.com/blog/en-us/',
+ 'https://example.com/blog/es/',
+ ]
+ );
});
it('should retrieve the correct list of base URL with locales [format: directory, trailingSlash: ignore, routingStategy: pathname-prefix-always-no-redirect]', () => {
@@ -1770,7 +1724,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
locale: 'en',
base: '/blog/',
@@ -1778,12 +1732,13 @@ describe('getLocaleAbsoluteUrlList', () => {
trailingSlash: 'ignore',
format: 'directory',
site: 'https://example.com',
- })
- ).to.have.members([
- 'https://example.com/blog/en/',
- 'https://example.com/blog/en-us/',
- 'https://example.com/blog/es/',
- ]);
+ }),
+ [
+ 'https://example.com/blog/en/',
+ 'https://example.com/blog/en-us/',
+ 'https://example.com/blog/es/',
+ ]
+ );
});
it('should retrieve the correct list of base URLs, swapped with the correct domain', () => {
@@ -1805,7 +1760,7 @@ describe('getLocaleAbsoluteUrlList', () => {
},
};
// directory format
- expect(
+ assert.deepEqual(
getLocaleAbsoluteUrlList({
base: '/blog/',
...config.experimental.i18n,
@@ -1813,26 +1768,27 @@ describe('getLocaleAbsoluteUrlList', () => {
format: 'directory',
site: 'https://example.com',
isBuild: true,
- })
- ).to.have.members([
- 'https://example.uk/blog/',
- 'https://example.com/blog/en-us/',
- 'https://es.example.com/blog/',
- ]);
+ }),
+ [
+ 'https://example.uk/blog/',
+ 'https://example.com/blog/en-us/',
+ 'https://es.example.com/blog/',
+ ]
+ );
});
});
describe('parse accept-header', () => {
it('should be parsed correctly', () => {
- expect(parseLocale('*')).to.have.deep.members([{ locale: '*', qualityValue: undefined }]);
- expect(parseLocale('fr')).to.have.deep.members([{ locale: 'fr', qualityValue: undefined }]);
- expect(parseLocale('fr;q=0.6')).to.have.deep.members([{ locale: 'fr', qualityValue: 0.6 }]);
- expect(parseLocale('fr;q=0.6,fr-CA;q=0.5')).to.have.deep.members([
+ assert.deepEqual(parseLocale('*'), [{ locale: '*', qualityValue: undefined }]);
+ assert.deepEqual(parseLocale('fr'), [{ locale: 'fr', qualityValue: undefined }]);
+ assert.deepEqual(parseLocale('fr;q=0.6'), [{ locale: 'fr', qualityValue: 0.6 }]);
+ assert.deepEqual(parseLocale('fr;q=0.6,fr-CA;q=0.5'), [
{ locale: 'fr', qualityValue: 0.6 },
{ locale: 'fr-CA', qualityValue: 0.5 },
]);
- expect(parseLocale('fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5')).to.have.deep.members([
+ assert.deepEqual(parseLocale('fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5'), [
{ locale: 'fr-CH', qualityValue: undefined },
{ locale: 'fr', qualityValue: 0.9 },
{ locale: 'en', qualityValue: 0.8 },
@@ -1842,18 +1798,9 @@ describe('parse accept-header', () => {
});
it('should not return incorrect quality values', () => {
- expect(parseLocale('wrong')).to.have.deep.members([
- { locale: 'wrong', qualityValue: undefined },
- ]);
- expect(parseLocale('fr;f=0.7')).to.have.deep.members([
- { locale: 'fr', qualityValue: undefined },
- ]);
- expect(parseLocale('fr;q=something')).to.have.deep.members([
- { locale: 'fr', qualityValue: undefined },
- ]);
-
- expect(parseLocale('fr;q=1000')).to.have.deep.members([
- { locale: 'fr', qualityValue: undefined },
- ]);
+ assert.deepEqual(parseLocale('wrong'), [{ locale: 'wrong', qualityValue: undefined }]);
+ assert.deepEqual(parseLocale('fr;f=0.7'), [{ locale: 'fr', qualityValue: undefined }]);
+ assert.deepEqual(parseLocale('fr;q=something'), [{ locale: 'fr', qualityValue: undefined }]);
+ assert.deepEqual(parseLocale('fr;q=1000'), [{ locale: 'fr', qualityValue: undefined }]);
});
});
diff --git a/packages/astro/test/units/integrations/api.test.js b/packages/astro/test/units/integrations/api.nodetest.js
index 882570db2..d4b0491c3 100644
--- a/packages/astro/test/units/integrations/api.test.js
+++ b/packages/astro/test/units/integrations/api.nodetest.js
@@ -1,7 +1,8 @@
-import { expect } from 'chai';
import { runHookBuildSetup, runHookConfigSetup } from '../../../dist/integrations/index.js';
import { validateSupportedFeatures } from '../../../dist/integrations/astroFeaturesValidation.js';
import { defaultLogger } from '../test-utils.js';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
describe('Integration API', () => {
it('runHookBuildSetup should work', async () => {
@@ -27,7 +28,7 @@ describe('Integration API', () => {
pages: new Map(),
target: 'server',
});
- expect(updatedViteConfig).to.haveOwnProperty('define');
+ assert.equal(updatedViteConfig.hasOwnProperty('define'), true);
});
it('runHookBuildSetup should return updated config', async () => {
@@ -54,7 +55,7 @@ describe('Integration API', () => {
pages: new Map(),
target: 'server',
});
- expect(updatedViteConfig).to.be.deep.equal(updatedInternalConfig);
+ assert.deepEqual(updatedViteConfig, updatedInternalConfig);
});
it('runHookConfigSetup can update Astro config', async () => {
@@ -76,7 +77,7 @@ describe('Integration API', () => {
},
},
});
- expect(updatedSettings.config.site).to.equal(site);
+ assert.equal(updatedSettings.config.site, site);
});
it('runHookConfigSetup runs integrations added by another integration', async () => {
@@ -110,8 +111,8 @@ describe('Integration API', () => {
},
},
});
- expect(updatedSettings.config.site).to.equal(site);
- expect(updatedSettings.config.integrations.length).to.equal(2);
+ assert.equal(updatedSettings.config.site, site);
+ assert.equal(updatedSettings.config.integrations.length, 2);
});
});
@@ -128,7 +129,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['hybridOutput']).to.be.true;
+ assert.equal(result['hybridOutput'], true);
});
it('should not support the feature when not provided', () => {
@@ -141,7 +142,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['hybridOutput']).to.be.false;
+ assert.equal(result['hybridOutput'], false);
});
it('should not support the feature when an empty object is provided', () => {
@@ -154,7 +155,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['hybridOutput']).to.be.false;
+ assert.equal(result['hybridOutput'], false);
});
describe('static output', function () {
@@ -168,7 +169,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['staticOutput']).to.be.true;
+ assert.equal(result['staticOutput'], true);
});
it("should not be valid if the config is correct, but the it's unsupported", () => {
@@ -181,7 +182,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['staticOutput']).to.be.false;
+ assert.equal(result['staticOutput'], false);
});
});
describe('hybrid output', function () {
@@ -195,7 +196,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['hybridOutput']).to.be.true;
+ assert.equal(result['hybridOutput'], true);
});
it("should not be valid if the config is correct, but the it's unsupported", () => {
@@ -210,7 +211,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['hybridOutput']).to.be.false;
+ assert.equal(result['hybridOutput'], false);
});
});
describe('server output', function () {
@@ -224,7 +225,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['serverOutput']).to.be.true;
+ assert.equal(result['serverOutput'], true);
});
it("should not be valid if the config is correct, but the it's unsupported", () => {
@@ -239,7 +240,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['serverOutput']).to.be.false;
+ assert.equal(result['serverOutput'], false);
});
});
@@ -263,7 +264,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['assets']).to.be.true;
+ assert.equal(result['assets'], true);
});
it('should be supported when it is squoosh compatible', () => {
let result = validateSupportedFeatures(
@@ -284,7 +285,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['assets']).to.be.true;
+ assert.equal(result['assets'], true);
});
it("should not be valid if the config is correct, but the it's unsupported", () => {
@@ -306,7 +307,7 @@ describe('Astro feature map', function () {
{},
defaultLogger
);
- expect(result['assets']).to.be.false;
+ assert.equal(result['assets'], false);
});
});
});
diff --git a/packages/astro/test/units/logger/locale.test.js b/packages/astro/test/units/logger/locale.nodetest.js
index c8e115f20..ddeadfc81 100644
--- a/packages/astro/test/units/logger/locale.test.js
+++ b/packages/astro/test/units/logger/locale.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it, after } from 'node:test';
+import * as assert from 'node:assert/strict';
const LOCALES = ['en_US', 'sv_SE', 'es_419.UTF-8', 'es_ES@euro', 'C'];
@@ -13,9 +14,9 @@ describe('logger - dateTimeFormat', () => {
it(`works with process.env.LANG="${locale}"`, async () => {
process.env.LANG = locale;
const { dateTimeFormat } = await import('../../../dist/core/logger/core.js?cachebust=' + i);
- expect(() => {
+ assert.doesNotThrow(() => {
dateTimeFormat.format(new Date());
- }).not.to.throw();
+ });
});
});
});
diff --git a/packages/astro/test/units/render/chunk.test.js b/packages/astro/test/units/render/chunk.nodetest.js
index b623f662f..035e98484 100644
--- a/packages/astro/test/units/render/chunk.test.js
+++ b/packages/astro/test/units/render/chunk.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import * as cheerio from 'cheerio';
import { fileURLToPath } from 'node:url';
import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js';
@@ -41,10 +42,10 @@ describe('core/render chunk', () => {
const $ = cheerio.load(html);
const target = $('#chunk');
- expect(target).not.to.be.undefined;
- expect(target.text()).to.equal('[object Object]');
+ assert.ok(target);
+ assert.equal(target.text(), '[object Object]');
} catch (e) {
- expect(false).to.be.ok;
+ assert.fail();
}
}
);
diff --git a/packages/astro/test/units/render/components.test.js b/packages/astro/test/units/render/components.nodetest.js
index cd27141f9..7fa36e864 100644
--- a/packages/astro/test/units/render/components.test.js
+++ b/packages/astro/test/units/render/components.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import * as cheerio from 'cheerio';
import { fileURLToPath } from 'node:url';
import { createFs, createRequestAndResponse, runInContainer } from '../test-utils.js';
@@ -47,11 +48,11 @@ describe('core/render components', () => {
const $ = cheerio.load(html);
const target = $('#target');
- expect(target).not.to.be.undefined;
- expect(target.attr('id')).to.equal('target');
- expect(target.attr('style')).to.be.undefined;
+ assert.ok(target);
+ assert.equal(target.attr('id'), 'target');
+ assert.equal(typeof target.attr('style'), 'undefined');
- expect($('#pwnd').length).to.equal(0);
+ assert.equal($('#pwnd').length, 0);
}
);
});
@@ -110,11 +111,11 @@ describe('core/render components', () => {
const BothFlipped = check('#both-flipped');
const BothSpread = check('#both-spread');
- expect(Class).to.deep.equal({ class: 'red blue' }, '#class');
- expect(ClassList).to.deep.equal({ class: 'red blue' }, '#class-list');
- expect(BothLiteral).to.deep.equal({ class: 'red blue' }, '#both-literal');
- expect(BothFlipped).to.deep.equal({ class: 'red blue' }, '#both-flipped');
- expect(BothSpread).to.deep.equal({ class: 'red blue' }, '#both-spread');
+ assert.deepEqual(Class, { class: 'red blue' }, '#class');
+ assert.deepEqual(ClassList, { class: 'red blue' }, '#class-list');
+ assert.deepEqual(BothLiteral, { class: 'red blue' }, '#both-literal');
+ assert.deepEqual(BothFlipped, { class: 'red blue' }, '#both-flipped');
+ assert.deepEqual(BothSpread, { class: 'red blue' }, '#both-spread');
}
);
});
diff --git a/packages/astro/test/units/render/head.test.js b/packages/astro/test/units/render/head.nodetest.js
index 1edd85d0d..ab84534aa 100644
--- a/packages/astro/test/units/render/head.test.js
+++ b/packages/astro/test/units/render/head.nodetest.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import { describe, it, before } from 'node:test';
+import * as assert from 'node:assert/strict';
import {
createComponent,
render,
@@ -104,8 +104,8 @@ describe('core/render', () => {
const html = await response.text();
const $ = cheerio.load(html);
- expect($('head link')).to.have.a.lengthOf(1);
- expect($('body link')).to.have.a.lengthOf(0);
+ assert.equal($('head link').length, 1);
+ assert.equal($('body link').length, 0);
});
it('Multi-level layouts and head injection, without explicit head', async () => {
@@ -186,8 +186,8 @@ describe('core/render', () => {
const html = await response.text();
const $ = cheerio.load(html);
- expect($('head link')).to.have.a.lengthOf(1);
- expect($('body link')).to.have.a.lengthOf(0);
+ assert.equal($('head link').length, 1);
+ assert.equal($('body link').length, 0);
});
it('Multi-level layouts and head injection, without any content in layouts', async () => {
@@ -234,7 +234,7 @@ describe('core/render', () => {
const html = await response.text();
const $ = cheerio.load(html);
- expect($('link')).to.have.a.lengthOf(1);
+ assert.equal($('link').length, 1);
});
});
});
diff --git a/packages/astro/test/units/render/jsx.test.js b/packages/astro/test/units/render/jsx.nodetest.js
index 0368cc6fc..757a0e35d 100644
--- a/packages/astro/test/units/render/jsx.test.js
+++ b/packages/astro/test/units/render/jsx.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it, before } from 'node:test';
+import * as assert from 'node:assert/strict';
import {
createComponent,
render,
@@ -51,10 +52,10 @@ describe('core/render', () => {
const pipeline = new Pipeline(env);
const response = await pipeline.renderRoute(ctx, mod);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
- expect(html).to.include('<div><p class="n">works</p></div>');
+ assert.equal(html.includes('<div><p class="n">works</p></div>'), true);
});
it('Can render slots with a dash in the name', async () => {
@@ -97,11 +98,14 @@ describe('core/render', () => {
const pipeline = new Pipeline(env);
const response = await pipeline.renderRoute(ctx, mod);
- expect(response.status).to.equal(200);
+ assert.equal(response.status, 200);
const html = await response.text();
- expect(html).to.include(
- '<main><div><p class="n">works</p></div><div><p class="p">works</p></div></main>'
+ assert.equal(
+ html.includes(
+ '<main><div><p class="n">works</p></div><div><p class="p">works</p></div></main>'
+ ),
+ true
);
});
@@ -127,9 +131,9 @@ describe('core/render', () => {
try {
await response.text();
- expect(false).to.equal(true, 'should not have been successful');
+ assert.equal(false, true, 'should not have been successful');
} catch (err) {
- expect(err.message).to.equal('uh oh');
+ assert.equal(err.message, 'uh oh');
}
});
});
diff --git a/packages/astro/test/units/routing/endpoints.test.js b/packages/astro/test/units/routing/endpoints.nodetest.js
index fde7a81da..c03a70802 100644
--- a/packages/astro/test/units/routing/endpoints.test.js
+++ b/packages/astro/test/units/routing/endpoints.nodetest.js
@@ -5,7 +5,8 @@ import {
defaultLogger,
} from '../test-utils.js';
import { fileURLToPath } from 'node:url';
-import { expect } from 'chai';
+import { describe, it, before, after } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createContainer } from '../../../dist/core/dev/container.js';
import testAdapter from '../../test-adapter.js';
@@ -47,9 +48,9 @@ describe('endpoints', () => {
container.handle(req, res);
await done;
const headers = res.getHeaders();
- expect(headers).to.deep.include({ location: 'https://example.com/destination' });
- expect(headers).not.to.deep.include({ 'x-astro-reroute': 'no' });
- expect(res.statusCode).to.equal(307);
+ assert.equal(headers['location'], 'https://example.com/destination');
+ assert.equal(headers['x-astro-reroute'], undefined);
+ assert.equal(res.statusCode, 307);
});
it('should return a response with location header', async () => {
@@ -60,9 +61,9 @@ describe('endpoints', () => {
container.handle(req, res);
await done;
const headers = res.getHeaders();
- expect(headers).to.deep.include({ location: 'https://example.com/destination' });
- expect(headers).not.to.deep.include({ 'x-astro-reroute': 'no' });
- expect(res.statusCode).to.equal(307);
+ assert.equal(headers['location'], 'https://example.com/destination');
+ assert.equal(headers['x-astro-reroute'], undefined);
+ assert.equal(res.statusCode, 307);
});
it('should append reroute header for HTTP status 404', async () => {
@@ -73,8 +74,8 @@ describe('endpoints', () => {
container.handle(req, res);
await done;
const headers = res.getHeaders();
- expect(headers).to.deep.include({ 'x-astro-reroute': 'no' });
- expect(res.statusCode).to.equal(404);
+ assert.equal(headers['x-astro-reroute'], 'no');
+ assert.equal(res.statusCode, 404);
});
it('should append reroute header for HTTP status 500', async () => {
@@ -85,7 +86,7 @@ describe('endpoints', () => {
container.handle(req, res);
await done;
const headers = res.getHeaders();
- expect(headers).to.deep.include({ 'x-astro-reroute': 'no' });
- expect(res.statusCode).to.equal(500);
+ assert.equal(headers['x-astro-reroute'], 'no');
+ assert.equal(res.statusCode, 500);
});
});
diff --git a/packages/astro/test/units/routing/manifest.test.js b/packages/astro/test/units/routing/manifest.nodetest.js
index fe09f628b..d7bbc8c0f 100644
--- a/packages/astro/test/units/routing/manifest.test.js
+++ b/packages/astro/test/units/routing/manifest.nodetest.js
@@ -1,5 +1,5 @@
-import { expect } from 'chai';
-
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { fileURLToPath } from 'node:url';
import { createRouteManifest } from '../../../dist/core/routing/manifest/create.js';
import { createBasicSettings, createFs } from '../test-utils.js';
@@ -45,8 +45,8 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
const [{ pattern }] = manifest.routes;
- expect(pattern.test('')).to.equal(true);
- expect(pattern.test('/')).to.equal(false);
+ assert.equal(pattern.test(''), true);
+ assert.equal(pattern.test('/'), false);
});
it('endpoint routes are sorted before page routes', async () => {
@@ -83,7 +83,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/about',
type: 'page',
@@ -128,7 +128,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/',
type: 'page',
@@ -179,7 +179,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/',
type: 'page',
@@ -255,7 +255,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/contributing',
type: 'page',
@@ -311,7 +311,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/blog/[...slug]',
type: 'page',
@@ -358,7 +358,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/blog/contributing',
type: 'page',
@@ -411,7 +411,7 @@ describe('routing - createRouteManifest', () => {
fsMod: fs,
});
- expect(getManifestRoutes(manifest)).to.deep.equal([
+ assert.deepEqual(getManifestRoutes(manifest), [
{
route: '/blog/about',
type: 'redirect',
@@ -466,7 +466,7 @@ describe('routing - createRouteManifest', () => {
createRouteManifest(manifestOptions, logger);
- expect(logs).to.deep.equal([
+ assert.deepEqual(logs, [
{
label: 'router',
level: 'warn',
@@ -512,7 +512,7 @@ describe('routing - createRouteManifest', () => {
createRouteManifest(manifestOptions, logger);
- expect(logs).to.deep.equal([
+ assert.deepEqual(logs, [
{
label: 'router',
level: 'warn',
diff --git a/packages/astro/test/units/routing/route-matching.test.js b/packages/astro/test/units/routing/route-matching.nodetest.js
index 6f4724893..0eeb47ca5 100644
--- a/packages/astro/test/units/routing/route-matching.test.js
+++ b/packages/astro/test/units/routing/route-matching.nodetest.js
@@ -7,7 +7,8 @@ import {
import { createRouteManifest, matchAllRoutes } from '../../../dist/core/routing/index.js';
import { fileURLToPath } from 'node:url';
import { createViteLoader } from '../../../dist/core/module-loader/vite.js';
-import { expect } from 'chai';
+import { describe, it, before, after } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createContainer } from '../../../dist/core/dev/container.js';
import * as cheerio from 'cheerio';
import testAdapter from '../../test-adapter.js';
@@ -166,7 +167,7 @@ describe('Route matching', () => {
const preloadedMatches = await getSortedPreloadedMatches({ pipeline, matches, settings });
const sortedRouteNames = preloadedMatches.map((match) => match.route.route);
- expect(sortedRouteNames).to.deep.equal([
+ assert.deepEqual(sortedRouteNames, [
'/[astaticdynamic]',
'/[xstaticdynamic]',
'/[serverdynamic]',
@@ -180,7 +181,7 @@ describe('Route matching', () => {
const preloadedMatches = await getSortedPreloadedMatches({ pipeline, matches, settings });
const sortedRouteNames = preloadedMatches.map((match) => match.route.route);
- expect(sortedRouteNames).to.deep.equal([
+ assert.deepEqual(sortedRouteNames, [
'/nested/[...astaticrest]',
'/nested/[...xstaticrest]',
'/nested/[...serverrest]',
@@ -200,7 +201,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Prerendered dynamic route!');
+ assert.equal($('p').text(), 'Prerendered dynamic route!');
});
it('should correctly match a static dynamic route II', async () => {
@@ -211,7 +212,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Another prerendered dynamic route!');
+ assert.equal($('p').text(), 'Another prerendered dynamic route!');
});
it('should correctly match a server dynamic route', async () => {
@@ -222,7 +223,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Server dynamic route! slug:a-random-slug-was-matched');
+ assert.equal($('p').text(), 'Server dynamic route! slug:a-random-slug-was-matched');
});
it('should correctly match a static rest route I', async () => {
@@ -233,7 +234,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Prerendered rest route!');
+ assert.equal($('p').text(), 'Prerendered rest route!');
});
it('should correctly match a static rest route II', async () => {
@@ -244,7 +245,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Another prerendered rest route!');
+ assert.equal($('p').text(), 'Another prerendered rest route!');
});
it('should correctly match a nested static rest route index', async () => {
@@ -255,7 +256,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Nested prerendered rest route!');
+ assert.equal($('p').text(), 'Nested prerendered rest route!');
});
it('should correctly match a nested static rest route', async () => {
@@ -266,7 +267,7 @@ describe('Route matching', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Another nested prerendered rest route!');
+ assert.equal($('p').text(), 'Another nested prerendered rest route!');
});
it('should correctly match a nested server rest route', async () => {
@@ -278,7 +279,7 @@ describe('Route matching', () => {
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Nested server rest route! slug: a-random-slug-was-matched');
+ assert.equal($('p').text(), 'Nested server rest route! slug: a-random-slug-was-matched');
});
});
});
diff --git a/packages/astro/test/units/routing/route-sanitization.test.js b/packages/astro/test/units/routing/route-sanitization.nodetest.js
index 14c9c3829..c2367055a 100644
--- a/packages/astro/test/units/routing/route-sanitization.test.js
+++ b/packages/astro/test/units/routing/route-sanitization.nodetest.js
@@ -5,7 +5,8 @@ import {
defaultLogger,
} from '../test-utils.js';
import { fileURLToPath } from 'node:url';
-import { expect } from 'chai';
+import { describe, it, before, after } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createContainer } from '../../../dist/core/dev/container.js';
import * as cheerio from 'cheerio';
import testAdapter from '../../test-adapter.js';
@@ -60,7 +61,7 @@ describe('Route sanitization', () => {
container.handle(req, res);
const html = await text();
const $ = cheerio.load(html);
- expect($('p').text()).to.equal('Success!');
+ assert.equal($('p').text(), 'Success!');
});
});
});
diff --git a/packages/astro/test/units/routing/trailing-slash.test.js b/packages/astro/test/units/routing/trailing-slash.nodetest.js
index 72eed92dd..292b32ff5 100644
--- a/packages/astro/test/units/routing/trailing-slash.test.js
+++ b/packages/astro/test/units/routing/trailing-slash.nodetest.js
@@ -5,7 +5,8 @@ import {
defaultLogger,
} from '../test-utils.js';
import { fileURLToPath } from 'node:url';
-import { expect } from 'chai';
+import { describe, it, before, after } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createContainer } from '../../../dist/core/dev/container.js';
import testAdapter from '../../test-adapter.js';
@@ -44,7 +45,7 @@ describe('trailingSlash', () => {
});
container.handle(req, res);
const json = await text();
- expect(json).to.equal('{"success":true}');
+ assert.equal(json, '{"success":true}');
});
it('should NOT match the API route when request lacks a trailing slash', async () => {
@@ -53,7 +54,7 @@ describe('trailingSlash', () => {
url: '/api',
});
container.handle(req, res);
- expect(await text()).to.equal('');
- expect(res.statusCode).to.equal(404);
+ assert.equal(await text(), '');
+ assert.equal(res.statusCode, 404);
});
});
diff --git a/packages/astro/test/units/runtime/astro-global.nodetest.js b/packages/astro/test/units/runtime/astro-global.nodetest.js
new file mode 100644
index 000000000..a7959a4ec
--- /dev/null
+++ b/packages/astro/test/units/runtime/astro-global.nodetest.js
@@ -0,0 +1,29 @@
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
+import { createAstro } from '../../../dist/runtime/server/index.js';
+
+describe('astro global', () => {
+ it('Glob should error if passed incorrect value', async () => {
+ const Astro = createAstro(undefined);
+ assert.throws(
+ () => {
+ Astro.glob('./**/*.md');
+ },
+ {
+ message: /can only be used in/,
+ }
+ );
+ });
+
+ it('Glob should error if has no results', async () => {
+ const Astro = createAstro(undefined);
+ assert.throws(
+ () => {
+ Astro.glob([], () => './**/*.md');
+ },
+ {
+ message: /did not return any matching files/,
+ }
+ );
+ });
+});
diff --git a/packages/astro/test/units/runtime/astro-global.test.js b/packages/astro/test/units/runtime/astro-global.test.js
deleted file mode 100644
index 59585de39..000000000
--- a/packages/astro/test/units/runtime/astro-global.test.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import { expect } from 'chai';
-import { createAstro } from '../../../dist/runtime/server/index.js';
-
-describe('astro global', () => {
- it('Glob should error if passed incorrect value', async () => {
- const Astro = createAstro(undefined);
- expect(() => {
- Astro.glob('./**/*.md');
- }).to.throw(/can only be used in/);
- });
-
- it('Glob should error if has no results', async () => {
- const Astro = createAstro(undefined);
- expect(() => {
- Astro.glob([], () => './**/*.md');
- }).to.throw(/did not return any matching files/);
- });
-});
diff --git a/packages/astro/test/units/vite-plugin-astro-server/controller.test.js b/packages/astro/test/units/vite-plugin-astro-server/controller.nodetest.js
index 0864d8964..345c2009d 100644
--- a/packages/astro/test/units/vite-plugin-astro-server/controller.test.js
+++ b/packages/astro/test/units/vite-plugin-astro-server/controller.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createLoader } from '../../../dist/core/module-loader/index.js';
import {
createController,
@@ -20,8 +21,8 @@ describe('vite-plugin-astro-server', () => {
error = err;
},
});
- expect(error).to.not.be.an('undefined');
- expect(error).to.be.an.instanceOf(Error);
+ assert.equal(typeof error !== 'undefined', true);
+ assert.equal(error instanceof Error, true);
});
it('sets the state to error when an error occurs in the handler', async () => {
@@ -34,7 +35,7 @@ describe('vite-plugin-astro-server', () => {
},
onError() {},
});
- expect(controller.state.state).to.equal('error');
+ assert.equal(controller.state.state, 'error');
});
it('calls reload when a file change occurs when in an error state', async () => {
@@ -47,7 +48,7 @@ describe('vite-plugin-astro-server', () => {
});
const controller = createController({ loader });
loader.events.emit('file-change');
- expect(reloads).to.equal(0);
+ assert.equal(reloads, 0);
await runWithErrorHandling({
controller,
pathname: '/',
@@ -56,9 +57,9 @@ describe('vite-plugin-astro-server', () => {
},
onError() {},
});
- expect(reloads).to.equal(0);
+ assert.equal(reloads, 0);
loader.events.emit('file-change');
- expect(reloads).to.equal(1);
+ assert.equal(reloads, 1);
});
it('does not call reload on file change if not in an error state', async () => {
@@ -71,7 +72,7 @@ describe('vite-plugin-astro-server', () => {
});
const controller = createController({ loader });
loader.events.emit('file-change');
- expect(reloads).to.equal(0);
+ assert.equal(reloads, 0);
await runWithErrorHandling({
controller,
pathname: '/',
@@ -80,11 +81,11 @@ describe('vite-plugin-astro-server', () => {
},
onError() {},
});
- expect(reloads).to.equal(0);
+ assert.equal(reloads, 0);
loader.events.emit('file-change');
- expect(reloads).to.equal(1);
+ assert.equal(reloads, 1);
loader.events.emit('file-change');
- expect(reloads).to.equal(2);
+ assert.equal(reloads, 2);
await runWithErrorHandling({
controller,
@@ -93,7 +94,7 @@ describe('vite-plugin-astro-server', () => {
run() {},
});
loader.events.emit('file-change');
- expect(reloads).to.equal(2);
+ assert.equal(reloads, 2);
});
it('Invalidates broken modules when a change occurs in an error state', async () => {
@@ -124,7 +125,7 @@ describe('vite-plugin-astro-server', () => {
loader.events.emit('file-change');
- expect(mods).to.deep.equal([
+ assert.deepEqual(mods, [
{ id: 'one', ssrError: null },
{ id: 'two', ssrError: null },
{ id: 'three', ssrError: null },
diff --git a/packages/astro/test/units/vite-plugin-astro-server/request.test.js b/packages/astro/test/units/vite-plugin-astro-server/request.nodetest.js
index d1d0cf464..f79c86f84 100644
--- a/packages/astro/test/units/vite-plugin-astro-server/request.test.js
+++ b/packages/astro/test/units/vite-plugin-astro-server/request.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createLoader } from '../../../dist/core/module-loader/index.js';
import { createRouteManifest } from '../../../dist/core/routing/index.js';
import { createComponent, render } from '../../../dist/runtime/server/index.js';
@@ -65,12 +66,12 @@ describe('vite-plugin-astro-server', () => {
incomingResponse: res,
});
} catch (err) {
- expect(err.message).to.be.undefined();
+ assert.equal(err.message, undefined);
}
const html = await text();
- expect(res.statusCode).to.equal(200);
- expect(html).to.include('<div id="test">');
+ assert.equal(res.statusCode, 200);
+ assert.equal(html.includes('<div id="test">'), true);
});
});
});
diff --git a/packages/astro/test/units/vite-plugin-astro-server/response.test.js b/packages/astro/test/units/vite-plugin-astro-server/response.nodetest.js
index 55ab1b380..861d1fcb2 100644
--- a/packages/astro/test/units/vite-plugin-astro-server/response.test.js
+++ b/packages/astro/test/units/vite-plugin-astro-server/response.nodetest.js
@@ -5,7 +5,8 @@ import {
defaultLogger,
} from '../test-utils.js';
import { fileURLToPath } from 'node:url';
-import { expect } from 'chai';
+import { describe, it, before, after } from 'node:test';
+import * as assert from 'node:assert/strict';
import { createContainer } from '../../../dist/core/dev/container.js';
import testAdapter from '../../test-adapter.js';
@@ -75,7 +76,7 @@ describe('endpoints', () => {
container.handle(req, res);
await done;
const headers = res.getHeaders();
- expect(headers).to.deep.equal({
+ assert.deepEqual(headers, {
'access-control-allow-origin': '*',
'x-single': 'single',
'x-triple': 'one, two, three',
@@ -99,6 +100,6 @@ describe('endpoints', () => {
await done;
- expect(locals).to.deep.equal({ cancelledByTheServer: true });
+ assert.deepEqual(locals, { cancelledByTheServer: true });
});
});
diff --git a/packages/astro/test/units/vite-plugin-astro/compile.test.js b/packages/astro/test/units/vite-plugin-astro/compile.nodetest.js
index c37506cfb..08b6c2810 100644
--- a/packages/astro/test/units/vite-plugin-astro/compile.test.js
+++ b/packages/astro/test/units/vite-plugin-astro/compile.nodetest.js
@@ -1,4 +1,5 @@
-import { expect } from 'chai';
+import { describe, it } from 'node:test';
+import * as assert from 'node:assert/strict';
import { resolveConfig } from 'vite';
import { compileAstro } from '../../../dist/vite-plugin-astro/compile.js';
import { init, parse } from 'es-module-lexer';
@@ -25,7 +26,7 @@ async function compile(source, id) {
describe('astro full compile', () => {
it('should compile a single file', async () => {
const result = await compile(`<h1>Hello World</h1>`, '/src/components/index.astro');
- expect(result.code).to.be.ok;
+ assert.ok(result.code);
});
it('should compile typescript', async () => {
@@ -38,7 +39,7 @@ const name: string = 'world'
<h1>Hello {name}</h1>`,
'/src/components/index.astro'
);
- expect(result.code).to.be.ok;
+ assert.ok(result.code);
});
it('should error on invalid js', async () => {
@@ -54,9 +55,9 @@ const name = 'world
'/src/components/index.astro'
);
} catch (e) {
- expect(e.message).to.include('Unterminated string literal');
+ assert.equal(e.message.includes('Unterminated string literal'), true);
}
- expect(result).to.be.undefined;
+ assert.equal(result, undefined);
});
it('has file and url exports for markdwon compat', async () => {
@@ -64,8 +65,8 @@ const name = 'world
await init;
const [, exports] = parse(result.code);
const names = exports.map((e) => e.n);
- expect(names).to.include('default');
- expect(names).to.include('file');
- expect(names).to.include('url');
+ assert.equal(names.includes('default'), true);
+ assert.equal(names.includes('file'), true);
+ assert.equal(names.includes('url'), true);
});
});
diff --git a/packages/astro/test/units/vite-plugin-scanner/scan.test.js b/packages/astro/test/units/vite-plugin-scanner/scan.nodetest.js
index 3d812a893..d1e389de0 100644
--- a/packages/astro/test/units/vite-plugin-scanner/scan.test.js
+++ b/packages/astro/test/units/vite-plugin-scanner/scan.nodetest.js
@@ -1,59 +1,63 @@
-import { expect } from 'chai';
+import { describe, it, before, after } from 'node:test';
+import * as assert from 'node:assert/strict';
import { scan } from '../../../dist/vite-plugin-scanner/scan.js';
describe('astro scan', () => {
it('should return empty object', async () => {
const result = await scan(`export {}`, '/src/components/index.astro');
- expect(Object.keys(result).length).to.equal(0);
+ assert.equal(Object.keys(result).length, 0);
});
it('recognizes constant boolean literal (false)', async () => {
const result = await scan(`export const prerender = true;`, '/src/components/index.astro');
- expect(result.prerender).to.equal(true);
+ assert.equal(result.prerender, true);
});
it('recognizes constant boolean literal (false)', async () => {
const result = await scan(`export const prerender = false;`, '/src/components/index.astro');
- expect(result.prerender).to.equal(false);
+ assert.equal(result.prerender, false);
});
it("recognizes single quoted boolean ('true')", async () => {
const result = await scan(`export const prerender = 'true';`, '/src/components/index.astro');
- expect(result.prerender).to.equal(true);
+ assert.equal(result.prerender, true);
});
it('recognizes double quoted boolean ("true")', async () => {
const result = await scan(`export const prerender = "true";`, '/src/components/index.astro');
- expect(result.prerender).to.equal(true);
+ assert.equal(result.prerender, true);
});
it('recognizes double quoted boolean ("false")', async () => {
const result = await scan(`export const prerender = "false";`, '/src/components/index.astro');
- expect(result.prerender).to.equal(false);
+ assert.equal(result.prerender, false);
});
it("recognizes single quoted boolean ('false')", async () => {
const result = await scan(`export const prerender = 'false';`, '/src/components/index.astro');
- expect(result.prerender).to.equal(false);
+ assert.equal(result.prerender, false);
});
it('recognizes number (1)', async () => {
const result = await scan(`export const prerender = 1;`, '/src/components/index.astro');
- expect(result.prerender).to.equal(true);
+ assert.equal(result.prerender, true);
});
it('recognizes number (0)', async () => {
const result = await scan(`export const prerender = 0;`, '/src/components/index.astro');
- expect(result.prerender).to.equal(false);
+ assert.equal(result.prerender, false);
});
it('throws on let boolean literal', async () => {
try {
await scan(`export let prerender = true;`, '/src/components/index.astro');
- expect(false).to.be.true;
+ assert.equal(false).to.be.true;
} catch (e) {
- expect(e.message).to.contain(
- `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ assert.equal(
+ e.message.includes(
+ `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ ),
+ true
);
}
});
@@ -61,10 +65,13 @@ describe('astro scan', () => {
it('throws on var boolean literal', async () => {
try {
await scan(`export var prerender = true;`, '/src/components/index.astro');
- expect(false).to.be.true;
+ assert.equal(false).to.be.true;
} catch (e) {
- expect(e.message).to.contain(
- `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ assert.equal(
+ e.message.includes(
+ `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ ),
+ true
);
}
});
@@ -72,10 +79,13 @@ describe('astro scan', () => {
it('throws on unknown values I', async () => {
try {
await scan(`export const prerender = !!value;`, '/src/components/index.astro');
- expect(false).to.be.true;
+ assert.equal(false).to.be.true;
} catch (e) {
- expect(e.message).to.contain(
- `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ assert.equal(
+ e.message.includes(
+ `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ ),
+ true
);
}
});
@@ -83,10 +93,13 @@ describe('astro scan', () => {
it('throws on unknown values II', async () => {
try {
await scan(`export const prerender = value;`, '/src/components/index.astro');
- expect(false).to.be.true;
+ assert.equal(false).to.be.true;
} catch (e) {
- expect(e.message).to.contain(
- `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ assert.equal(
+ e.message.includes(
+ `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ ),
+ true
);
}
});
@@ -97,10 +110,13 @@ describe('astro scan', () => {
`export let prerender = undefined; prerender = true;`,
'/src/components/index.astro'
);
- expect(false).to.be.true;
+ assert.equal(false).to.be.true;
} catch (e) {
- expect(e.message).to.contain(
- `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ assert.equal(
+ e.message.includes(
+ `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ ),
+ true
);
}
});
@@ -108,10 +124,13 @@ describe('astro scan', () => {
it('throws on unknown values IV', async () => {
try {
await scan(`let prerender = true; export { prerender }`, '/src/components/index.astro');
- expect(false).to.be.true;
+ assert.equal(false).to.be.true;
} catch (e) {
- expect(e.message).to.contain(
- `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ assert.equal(
+ e.message.includes(
+ `A \`prerender\` export has been detected, but its value cannot be statically analyzed.`
+ ),
+ true
);
}
});