0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

chore(@astrojs/underscore-redirects): use Node.js for testing (#9923)

* chore: migrate underscore-redirects tests to node

* fix: remove chai/mocha devDependencies

* Update packages/underscore-redirects/package.json

* update lockfile

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
Atharva 2024-02-02 17:08:17 +05:30 committed by GitHub
parent 8578159194
commit a79db060b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 21 additions and 27 deletions

View file

@ -25,15 +25,11 @@
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"postbuild": "astro-scripts copy \"src/**/*.js\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "mocha --exit --timeout 20000"
"test": "astro-scripts test \"test/**/*.test.js\""
},
"devDependencies": {
"@types/chai": "^4.3.10",
"@types/mocha": "^10.0.4",
"astro": "workspace:*",
"astro-scripts": "workspace:*",
"chai": "^4.3.7",
"mocha": "^10.2.0"
"astro-scripts": "workspace:*"
},
"keywords": [
"astro",

View file

@ -1,5 +1,6 @@
import { createRedirectsFromAstroRoutes } from '../dist/index.js';
import { expect } from 'chai';
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
describe('Astro', () => {
const serverConfig = {
@ -26,6 +27,6 @@ describe('Astro', () => {
dir: new URL(import.meta.url),
});
expect(_redirects.definitions).to.have.a.lengthOf(2);
assert.equal(_redirects.definitions.length, 2);
});
});

View file

@ -1,5 +1,6 @@
import { Redirects } from '../dist/index.js';
import { expect } from 'chai';
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
describe('Printing', () => {
it('Formats long lines in a pretty way', () => {
@ -22,8 +23,13 @@ describe('Printing', () => {
let [lineOne, lineTwo] = out.split('\n');
expect(lineOne.indexOf('/b')).to.equal(lineTwo.indexOf('/b'), 'destinations lined up');
expect(lineOne.indexOf('200')).to.equal(lineTwo.indexOf('200'), 'statuses lined up');
const indexLineOne = lineOne.indexOf('/b');
const indexLineTwo = lineTwo.indexOf('/b');
assert.equal(indexLineOne, indexLineTwo, 'destinations lined up');
const newIndexLineOne = lineOne.indexOf('200');
const newIndexLineTwo = lineTwo.indexOf('200');
assert.equal(newIndexLineOne, newIndexLineTwo, 'statuses lined up');
});
it('Properly prints dynamic routes', () => {
@ -37,6 +43,8 @@ describe('Printing', () => {
});
let out = _redirects.print();
let parts = out.split(/\s+/);
expect(parts).to.deep.equal(['/pets/:cat', '/pets/:cat/index.html', '200']);
const expectedParts = ['/pets/:cat', '/pets/:cat/index.html', '200'];
assert.deepEqual(parts, expectedParts);
});
});

View file

@ -1,5 +1,6 @@
import { Redirects } from '../dist/index.js';
import { expect } from 'chai';
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
describe('Weight', () => {
it('Puts higher weighted definitions on top', () => {
@ -26,7 +27,7 @@ describe('Weight', () => {
status: 200,
});
const firstDefn = _redirects.definitions[0];
expect(firstDefn.weight).to.equal(1);
expect(firstDefn.input).to.equal('/e');
assert.equal(firstDefn.weight, 1);
assert.equal(firstDefn.input, '/e');
});
});

View file

@ -5156,24 +5156,12 @@ importers:
packages/underscore-redirects:
devDependencies:
'@types/chai':
specifier: ^4.3.10
version: 4.3.11
'@types/mocha':
specifier: ^10.0.4
version: 10.0.6
astro:
specifier: workspace:*
version: link:../astro
astro-scripts:
specifier: workspace:*
version: link:../../scripts
chai:
specifier: ^4.3.7
version: 4.3.10
mocha:
specifier: ^10.2.0
version: 10.2.0
packages/upgrade:
dependencies: