Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"scripts": {
"create-patch": "node tools/create-patch.js",
"curate": "node tools/prepare-curated.js ed curated && node tools/prepare-packages.js curated packages",
"test": "mocha --recursive",
"test-css": "mocha --recursive test/css",
"test-elements": "mocha --recursive test/elements",
"test-idl": "mocha --recursive test/idl"
"test": "node --test",
"test-css": "node --test \"test/css/*.js\"",
"test-elements": "node --test \"test/elements/*.js\"",
"test-idl": "node --test \"test/idl/*.js\""
}
}
6 changes: 3 additions & 3 deletions test/cddl/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* The tests run against the curated view of the extracts.
*/

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -19,9 +20,8 @@ function writeAnomalies(report) {
report.map(anomaly => anomaly.content).join('\n');
}

describe('The curated view of CDDL extracts', function () {
// First run may download micropip and cddlparser packages from the net
this.timeout(30000);
describe('The curated view of CDDL extracts', {timeout: 30000}, function () {
// Long timeout as first run may download micropip and cddlparser packages

it('passes Strudy\'s scrutiny', async function () {
const crawlFile = path.join(curatedFolder, 'index.json');
Expand Down
1 change: 1 addition & 0 deletions test/css/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* data because that view is a strict subset of the curated view.
*/

import { describe, it, before } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down
1 change: 1 addition & 0 deletions test/css/package.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';

import cssPackage from '../../packages/css/package.json' with { type: 'json' };
Expand Down
2 changes: 1 addition & 1 deletion test/elements/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* the data because that view is a strict subset of the curated view.
*/

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -17,7 +18,6 @@ const curatedFolder = path.join(scriptPath, '..', '..', 'curated', 'elements');

describe('The curated view of elements extracts', function () {
it('contains valid JSON and expected properties', async function () {
this.slow(5000);

const all = await elements.listAll({ folder: curatedFolder });
assert(Object.keys(all).length > 0);
Expand Down
1 change: 1 addition & 0 deletions test/elements/consistency.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* view because of some missing IDL definition in that view.
*/

import { describe, it, before } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down
3 changes: 2 additions & 1 deletion test/events/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* the data because that view is a strict subset of the curated view.
*/

import { describe, it, before } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -146,4 +147,4 @@ describe('The curated view of events extracts', () => {
// Dummy test to make sure that "before" function runs and has a place
// to report runtime errors
it('contains events', () => {});
});
});
2 changes: 1 addition & 1 deletion test/idl/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* data because that view is a strict subset of the curated view.
*/

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -16,7 +17,6 @@ const scriptPath = path.dirname(fileURLToPath(import.meta.url));
const curatedFolder = path.join(scriptPath, '..', '..', 'curated', 'idl');

describe('The curated view of Web IDL extracts', function () {
this.slow(5000);

it('contains valid JSON and expected properties', async function () {
const files = await idl.listAll({ folder: curatedFolder });
Expand Down
3 changes: 2 additions & 1 deletion test/idl/consistency.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* view because of some missing IDL definition in that view.
*/

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand Down Expand Up @@ -59,4 +60,4 @@ views.forEach(({ name, folder }) => {
assert.equal(results.length, 0, writeAnomalies(results));
});
});
});
});
1 change: 1 addition & 0 deletions test/idl/package.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';

import idlPackage from '../../packages/idl/package.json' with { type: 'json' };
Expand Down
53 changes: 25 additions & 28 deletions test/idl/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* the package view, e.g. due to missing base interfaces.
*/

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
Expand All @@ -20,6 +21,7 @@ const curatedView = {
name: 'curated',
folder: path.join(scriptPath, '..', '..', 'curated', 'idl')
};

const packageView = {
name: '@webref/idl package',
folder: path.join(scriptPath, '..', '..', 'packages', 'idl')
Expand All @@ -40,44 +42,39 @@ function validate(ast) {
assert.fail(message);
}

describe(`The ${curatedView.name} view of Web IDL extracts`, function () {
before(async () => {
const all = await idl.parseAll(curatedView.folder);
describe(`The ${curatedView.name} view of Web IDL extracts`, async function () {
let all;
try {
all = await idl.parseAll({folder: curatedView.folder});
} catch (err) {
it('contains data that can be parsed with webidl2.js', () => {throw err ;});
};

describe(`The ${curatedView.name} view of Web IDL extracts`, function () {
for (const [spec, ast] of Object.entries(all)) {
it(`contains valid Web IDL for ${spec}`, function () {
validate(ast);
});
}
for (const [spec, ast] of Object.entries(all)) {
it(`contains valid Web IDL for ${spec}`, function () {
validate(ast);
});

describe(`The combined Web IDL in the ${curatedView.name} view`, function () {
it('is valid Web IDL', function () {
this.slow(1000);
validate(Object.values(all).flat());
});
}
describe(`The combined Web IDL in the ${curatedView.name} view`, function () {
it('is valid Web IDL', function () {
validate(Object.values(all).flat());
});
});

// Dummy test needed for "before" to run and register late tests
// (test will fail if before function throws, e.g. because data is invalid)
it('contains data that can be parsed with webidl2.js', () => {});
});


describe(`The ${packageView.name} view of Web IDL extracts`, async () => {
before(async () => {
const all = await idl.parseAll(packageView.folder);
let all;
try {
all = await idl.parseAll({folder: packageView.folder});
} catch (err) {
it('contains data that can be parsed with webidl2.js', () => {throw err;});
}

describe(`The combined Web IDL in the ${packageView.name} view`, function () {
it('is valid Web IDL', function () {
this.slow(1000);
validate(Object.values(all).flat());
});
describe(`The combined Web IDL in the ${packageView.name} view`, function () {
it('is valid Web IDL', function () {
validate(Object.values(all).flat());
});
});

it('contains data that can be parsed with webidl2.js', () => {});
});

1 change: 1 addition & 0 deletions test/schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* The tests run against the curated view of the extracts.
*/

import { describe, it } from 'node:test';
import { strict as assert } from 'node:assert';
import fs from 'node:fs';
import path from 'node:path';
Expand Down