chore: fix doclint tests (#1098)
This fixes the doclint tests so that `npm test` works. It also adds all the browsers to npm test. Fixes #8
This commit is contained in:
parent
6acc439450
commit
b50e8b377f
|
|
@ -21,7 +21,7 @@
|
|||
"wunit": "npm run wtest",
|
||||
"debug-test": "node --inspect-brk test/test.js",
|
||||
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
|
||||
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && node utils/testrunner/test/test.js",
|
||||
"test": "npm run lint --silent && npm run ccoverage && npm run fcoverage && npm run wcoverage && npm run test-doclint && node utils/testrunner/test/test.js",
|
||||
"prepare": "node prepare.js",
|
||||
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src) && npm run tsc && npm run doc",
|
||||
"doc": "node utils/doclint/cli.js",
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ Documentation.Class = class {
|
|||
}
|
||||
}
|
||||
|
||||
validateOrder(errors) {
|
||||
validateOrder(errors, cls) {
|
||||
const members = this.membersArray;
|
||||
// Events should go first.
|
||||
let eventIndex = 0;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ module.exports = { checkSources, expandPrefix };
|
|||
function checkSources(sources, externalDependencies) {
|
||||
// special treatment for Events.js
|
||||
const classEvents = new Map();
|
||||
const eventsSources = sources.filter(source => source.name().startsWith('events.ts'));
|
||||
const eventsSources = sources.filter(source => source.name().startsWith('events.'));
|
||||
for (const eventsSource of eventsSources) {
|
||||
const {Events} = require(eventsSource.filePath().endsWith('.js') ? eventsSource.filePath() : eventsSource.filePath().replace(/\bsrc\b/, 'lib').replace('.ts', '.js'));
|
||||
for (const [className, events] of Object.entries(Events))
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ module.exports = async function(page, sources) {
|
|||
|
||||
// Push base class documentation to derived classes.
|
||||
for (const [name, clazz] of documentation.classes.entries()) {
|
||||
clazz.validateOrder(errors);
|
||||
clazz.validateOrder(errors, clazz);
|
||||
|
||||
if (!clazz.extends || clazz.extends === 'EventEmitter' || clazz.extends === 'Error')
|
||||
continue;
|
||||
|
|
|
|||
13
utils/doclint/check_public_api/test/check-duplicates/api.ts
Normal file
13
utils/doclint/check_public_api/test/check-duplicates/api.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class Foo {
|
||||
test() {
|
||||
}
|
||||
|
||||
title(arg: number) {
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
}
|
||||
|
||||
export {Bar};
|
||||
export {Foo};
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
class Foo {
|
||||
test() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} arg
|
||||
*/
|
||||
title(arg) {
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
}
|
||||
|
|
@ -18,3 +18,5 @@ class Foo {
|
|||
async asyncFunction() {
|
||||
}
|
||||
}
|
||||
|
||||
export {Foo};
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
class Foo {
|
||||
constructor() {
|
||||
this.ddd = 10;
|
||||
}
|
||||
ddd = 10;
|
||||
|
||||
aaa() {}
|
||||
|
||||
|
|
@ -10,3 +8,4 @@ class Foo {
|
|||
ccc() {}
|
||||
}
|
||||
|
||||
export {Foo};
|
||||
11
utils/doclint/check_public_api/test/diff-arguments/api.ts
Normal file
11
utils/doclint/check_public_api/test/diff-arguments/api.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class Foo {
|
||||
foo(arg1: string, arg3 = {}) {
|
||||
}
|
||||
|
||||
test(...filePaths : string[]) {
|
||||
}
|
||||
|
||||
bar(options: {visibility?: boolean}) {
|
||||
}
|
||||
}
|
||||
export {Foo};
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
class Foo {
|
||||
/**
|
||||
* @param {string} arg1
|
||||
*/
|
||||
foo(arg1, arg3 = {}) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {...string} filePaths
|
||||
*/
|
||||
test(...filePaths) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{visibility?: boolean}} options
|
||||
*/
|
||||
bar(options) {
|
||||
}
|
||||
}
|
||||
2
utils/doclint/check_public_api/test/diff-classes/api.ts
Normal file
2
utils/doclint/check_public_api/test/diff-classes/api.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export {Foo} from './foo';
|
||||
export {Other} from './other';
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
class Foo {
|
||||
}
|
||||
2
utils/doclint/check_public_api/test/diff-classes/foo.ts
Normal file
2
utils/doclint/check_public_api/test/diff-classes/foo.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export class Foo {
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
class Other {
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
export class Other {
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
class Foo {
|
||||
}
|
||||
|
||||
export {Foo};
|
||||
|
|
@ -14,3 +14,5 @@ class Foo {
|
|||
money$$money() {
|
||||
}
|
||||
}
|
||||
|
||||
export {Foo};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class Foo {
|
||||
a = 42;
|
||||
b = 'hello';
|
||||
}
|
||||
export {Foo};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
class Foo {
|
||||
constructor() {
|
||||
this.a = 42;
|
||||
this.b = 'hello';
|
||||
this.emit('done');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
class A {
|
||||
property1 = 1;
|
||||
_property2 = 2;
|
||||
constructor(delegate) {
|
||||
this.property1 = 1;
|
||||
this._property2 = 2;
|
||||
}
|
||||
|
||||
get getter() {
|
||||
|
|
@ -11,3 +11,5 @@ class A {
|
|||
async method(foo, bar) {
|
||||
}
|
||||
}
|
||||
|
||||
export {A};
|
||||
|
|
@ -13,3 +13,6 @@ class B extends A {
|
|||
bar(override) {
|
||||
}
|
||||
}
|
||||
|
||||
export {A};
|
||||
export {B};
|
||||
|
|
@ -34,7 +34,7 @@ let browserContext;
|
|||
let page;
|
||||
|
||||
beforeAll(async function() {
|
||||
browser = await playwright.launch();
|
||||
browser = await playwright.chromium.launch();
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
|
|
@ -65,8 +65,9 @@ async function testLint(state, test) {
|
|||
});
|
||||
|
||||
const mdSources = await Source.readdir(dirPath, '.md');
|
||||
const tsSources = await Source.readdir(dirPath, '.ts');
|
||||
const jsSources = await Source.readdir(dirPath, '.js');
|
||||
const messages = await checkPublicAPI(page, mdSources, jsSources);
|
||||
const messages = await checkPublicAPI(page, mdSources, jsSources.concat(tsSources));
|
||||
const errors = messages.map(message => message.text);
|
||||
expect(errors.join('\n')).toBeGolden('result.txt');
|
||||
}
|
||||
|
|
@ -86,8 +87,9 @@ async function testJSBuilder(state, test) {
|
|||
const {expect} = new Matchers({
|
||||
toBeGolden: GoldenUtils.compare.bind(null, dirPath, dirPath)
|
||||
});
|
||||
const sources = await Source.readdir(dirPath, '.js');
|
||||
const {documentation} = await jsBuilder(sources);
|
||||
const jsSources = await Source.readdir(dirPath, '.js');
|
||||
const tsSources = await Source.readdir(dirPath, '.ts');
|
||||
const {documentation} = await jsBuilder.checkSources(jsSources.concat(tsSources));
|
||||
expect(serialize(documentation)).toBeGolden('result.txt');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue