summaryrefslogtreecommitdiff
path: root/packages/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations')
-rw-r--r--packages/integrations/sitemap/package.json4
-rw-r--r--packages/integrations/sitemap/test/base-path.test.js7
-rw-r--r--packages/integrations/sitemap/test/filter.test.js7
-rw-r--r--packages/integrations/sitemap/test/routes.test.js7
-rw-r--r--packages/integrations/sitemap/test/ssr.test.js7
-rw-r--r--packages/integrations/sitemap/test/staticPaths.test.js15
-rw-r--r--packages/integrations/sitemap/test/trailing-slash.test.js15
7 files changed, 29 insertions, 33 deletions
diff --git a/packages/integrations/sitemap/package.json b/packages/integrations/sitemap/package.json
index 2bc76067d..c50359c73 100644
--- a/packages/integrations/sitemap/package.json
+++ b/packages/integrations/sitemap/package.json
@@ -30,7 +30,7 @@
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
- "test": "astro-scripts test \"test/**/*.test.js\""
+ "test": "mocha --timeout 20000"
},
"dependencies": {
"sitemap": "^7.1.1",
@@ -40,6 +40,8 @@
"@astrojs/node": "workspace:*",
"astro": "workspace:*",
"astro-scripts": "workspace:*",
+ "chai": "^4.3.7",
+ "mocha": "^10.2.0",
"xml2js": "0.6.2"
},
"publishConfig": {
diff --git a/packages/integrations/sitemap/test/base-path.test.js b/packages/integrations/sitemap/test/base-path.test.js
index 96bf5e209..a90f28c30 100644
--- a/packages/integrations/sitemap/test/base-path.test.js
+++ b/packages/integrations/sitemap/test/base-path.test.js
@@ -1,6 +1,5 @@
import { loadFixture, readXML } from './test-utils.js';
-import * as assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
+import { expect } from 'chai';
describe('URLs with base path', () => {
/** @type {import('./test-utils').Fixture} */
@@ -18,7 +17,7 @@ describe('URLs with base path', () => {
it('Base path is concatenated correctly', async () => {
const data = await readXML(fixture.readFile('/client/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/base/one/');
+ expect(urls[0].loc[0]).to.equal('http://example.com/base/one/');
});
});
@@ -34,7 +33,7 @@ describe('URLs with base path', () => {
it('Base path is concatenated correctly', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/base/123/');
+ expect(urls[0].loc[0]).to.equal('http://example.com/base/123/');
});
});
});
diff --git a/packages/integrations/sitemap/test/filter.test.js b/packages/integrations/sitemap/test/filter.test.js
index c8c00e1e7..b26232481 100644
--- a/packages/integrations/sitemap/test/filter.test.js
+++ b/packages/integrations/sitemap/test/filter.test.js
@@ -1,7 +1,6 @@
import { loadFixture, readXML } from './test-utils.js';
+import { expect } from 'chai';
import { sitemap } from './fixtures/static/deps.mjs';
-import * as assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
describe('Filter support', () => {
/** @type {import('./test-utils.js').Fixture} */
@@ -23,7 +22,7 @@ describe('Filter support', () => {
it('Just one page is added', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls.length, 1);
+ expect(urls.length).to.equal(1);
});
});
@@ -43,7 +42,7 @@ describe('Filter support', () => {
it('Just one page is added', async () => {
const data = await readXML(fixture.readFile('/client/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls.length, 1);
+ expect(urls.length).to.equal(1);
});
});
});
diff --git a/packages/integrations/sitemap/test/routes.test.js b/packages/integrations/sitemap/test/routes.test.js
index b7f39e404..909580dd9 100644
--- a/packages/integrations/sitemap/test/routes.test.js
+++ b/packages/integrations/sitemap/test/routes.test.js
@@ -1,6 +1,5 @@
import { loadFixture, readXML } from './test-utils.js';
-import * as assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
+import { expect } from 'chai';
describe('routes', () => {
/** @type {import('./test-utils.js').Fixture} */
@@ -18,10 +17,10 @@ describe('routes', () => {
});
it('does not include endpoints', async () => {
- assert.equal(urls.indexOf('http://example.com/endpoint.json'), -1);
+ expect(urls).to.not.include('http://example.com/endpoint.json');
});
it('does not include redirects', async () => {
- assert.equal(urls.indexOf('http://example.com/endpoint.json'), -1);
+ expect(urls).to.not.include('http://example.com/redirect');
});
});
diff --git a/packages/integrations/sitemap/test/ssr.test.js b/packages/integrations/sitemap/test/ssr.test.js
index 7622f266b..e6f8412d5 100644
--- a/packages/integrations/sitemap/test/ssr.test.js
+++ b/packages/integrations/sitemap/test/ssr.test.js
@@ -1,6 +1,5 @@
import { loadFixture, readXML } from './test-utils.js';
-import * as assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
+import { expect } from 'chai';
describe('SSR support', () => {
/** @type {import('./test-utils.js').Fixture} */
@@ -17,7 +16,7 @@ describe('SSR support', () => {
const data = await readXML(fixture.readFile('/client/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/one/');
- assert.equal(urls[1].loc[0], 'http://example.com/two/');
+ expect(urls[0].loc[0]).to.equal('http://example.com/one/');
+ expect(urls[1].loc[0]).to.equal('http://example.com/two/');
});
});
diff --git a/packages/integrations/sitemap/test/staticPaths.test.js b/packages/integrations/sitemap/test/staticPaths.test.js
index b4463c0d2..603af163d 100644
--- a/packages/integrations/sitemap/test/staticPaths.test.js
+++ b/packages/integrations/sitemap/test/staticPaths.test.js
@@ -1,6 +1,5 @@
import { loadFixture, readXML } from './test-utils.js';
-import * as assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
+import { expect } from 'chai';
describe('getStaticPaths support', () => {
/** @type {import('./test-utils.js').Fixture} */
@@ -20,24 +19,24 @@ describe('getStaticPaths support', () => {
});
it('requires zero config for getStaticPaths', async () => {
- assert.strictEqual(urls.includes('http://example.com/one/'), true);
- assert.strictEqual(urls.includes('http://example.com/two/'), true);
+ expect(urls).to.include('http://example.com/one/');
+ expect(urls).to.include('http://example.com/two/');
});
it('does not include 404 pages', () => {
- assert.strictEqual(urls.includes('http://example.com/de/404/'), false);
+ expect(urls).to.not.include('http://example.com/404/');
});
it('does not include nested 404 pages', () => {
- assert.strictEqual(urls.includes('http://example.com/de/404/'), false);
+ expect(urls).to.not.include('http://example.com/de/404/');
});
it('includes numerical pages', () => {
- assert.strictEqual(urls.includes('http://example.com/123/'), true);
+ expect(urls).to.include('http://example.com/123/');
});
it('should render the endpoint', async () => {
const page = await fixture.readFile('./it/manifest');
- assert.strictEqual(page.includes('I\'m a route in the "it" language.'), true);
+ expect(page).to.contain('I\'m a route in the "it" language.');
});
});
diff --git a/packages/integrations/sitemap/test/trailing-slash.test.js b/packages/integrations/sitemap/test/trailing-slash.test.js
index d51ed2020..a393fb9f1 100644
--- a/packages/integrations/sitemap/test/trailing-slash.test.js
+++ b/packages/integrations/sitemap/test/trailing-slash.test.js
@@ -1,6 +1,5 @@
import { loadFixture, readXML } from './test-utils.js';
-import * as assert from 'node:assert/strict';
-import { describe, it, before } from 'node:test';
+import { expect } from 'chai';
describe('Trailing slash', () => {
/** @type {import('./test-utils').Fixture} */
@@ -22,7 +21,7 @@ describe('Trailing slash', () => {
it('URLs end with trailing slash', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/one/');
+ expect(urls[0].loc[0]).to.equal('http://example.com/one/');
});
});
@@ -41,7 +40,7 @@ describe('Trailing slash', () => {
it('URLs do not end with trailing slash', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/one');
+ expect(urls[0].loc[0]).to.equal('http://example.com/one');
});
});
});
@@ -58,7 +57,7 @@ describe('Trailing slash', () => {
it('URLs do no end with trailing slash', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/one');
+ expect(urls[0].loc[0]).to.equal('http://example.com/one');
});
describe('with base path', () => {
before(async () => {
@@ -73,7 +72,7 @@ describe('Trailing slash', () => {
it('URLs do not end with trailing slash', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/base/one');
+ expect(urls[0].loc[0]).to.equal('http://example.com/base/one');
});
});
});
@@ -90,7 +89,7 @@ describe('Trailing slash', () => {
it('URLs end with trailing slash', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/one/');
+ expect(urls[0].loc[0]).to.equal('http://example.com/one/');
});
describe('with base path', () => {
before(async () => {
@@ -105,7 +104,7 @@ describe('Trailing slash', () => {
it('URLs end with trailing slash', async () => {
const data = await readXML(fixture.readFile('/sitemap-0.xml'));
const urls = data.urlset.url;
- assert.equal(urls[0].loc[0], 'http://example.com/base/one/');
+ expect(urls[0].loc[0]).to.equal('http://example.com/base/one/');
});
});
});