Skip to content

Commit b50e8b3

Browse files
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
1 parent 6acc439 commit b50e8b3

File tree

26 files changed

+59
-56
lines changed

26 files changed

+59
-56
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"wunit": "npm run wtest",
2222
"debug-test": "node --inspect-brk test/test.js",
2323
"test-doclint": "node utils/doclint/check_public_api/test/test.js && node utils/doclint/preprocessor/test.js",
24-
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && node utils/testrunner/test/test.js",
24+
"test": "npm run lint --silent && npm run ccoverage && npm run fcoverage && npm run wcoverage && npm run test-doclint && node utils/testrunner/test/test.js",
2525
"prepare": "node prepare.js",
2626
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe --ext js,ts ./src || eslint --ext js,ts ./src) && npm run tsc && npm run doc",
2727
"doc": "node utils/doclint/cli.js",

utils/doclint/check_public_api/Documentation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Documentation.Class = class {
7373
}
7474
}
7575

76-
validateOrder(errors) {
76+
validateOrder(errors, cls) {
7777
const members = this.membersArray;
7878
// Events should go first.
7979
let eventIndex = 0;

utils/doclint/check_public_api/JSBuilder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = { checkSources, expandPrefix };
2828
function checkSources(sources, externalDependencies) {
2929
// special treatment for Events.js
3030
const classEvents = new Map();
31-
const eventsSources = sources.filter(source => source.name().startsWith('events.ts'));
31+
const eventsSources = sources.filter(source => source.name().startsWith('events.'));
3232
for (const eventsSource of eventsSources) {
3333
const {Events} = require(eventsSource.filePath().endsWith('.js') ? eventsSource.filePath() : eventsSource.filePath().replace(/\bsrc\b/, 'lib').replace('.ts', '.js'));
3434
for (const [className, events] of Object.entries(Events))

utils/doclint/check_public_api/MDBuilder.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ module.exports = async function(page, sources) {
306306

307307
// Push base class documentation to derived classes.
308308
for (const [name, clazz] of documentation.classes.entries()) {
309-
clazz.validateOrder(errors);
309+
clazz.validateOrder(errors, clazz);
310310

311311
if (!clazz.extends || clazz.extends === 'EventEmitter' || clazz.extends === 'Error')
312312
continue;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Foo {
2+
test() {
3+
}
4+
5+
title(arg: number) {
6+
}
7+
}
8+
9+
class Bar {
10+
}
11+
12+
export {Bar};
13+
export {Foo};

utils/doclint/check_public_api/test/check-duplicates/foo.js

-13
This file was deleted.

utils/doclint/check_public_api/test/check-returns/foo.js utils/doclint/check_public_api/test/check-returns/api.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ class Foo {
1818
async asyncFunction() {
1919
}
2020
}
21+
22+
export {Foo};
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
class Foo {
2-
constructor() {
3-
this.ddd = 10;
4-
}
2+
ddd = 10;
53

64
aaa() {}
75

@@ -10,3 +8,4 @@ class Foo {
108
ccc() {}
119
}
1210

11+
export {Foo};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Foo {
2+
foo(arg1: string, arg3 = {}) {
3+
}
4+
5+
test(...filePaths : string[]) {
6+
}
7+
8+
bar(options: {visibility?: boolean}) {
9+
}
10+
}
11+
export {Foo};

utils/doclint/check_public_api/test/diff-arguments/foo.js

-19
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export {Foo} from './foo';
2+
export {Other} from './other';

utils/doclint/check_public_api/test/diff-classes/foo.js

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export class Foo {
2+
}

utils/doclint/check_public_api/test/diff-classes/other.js

-2
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export class Other {
2+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
class Foo {
22
}
33

4+
export {Foo};

utils/doclint/check_public_api/test/diff-methods/foo.js utils/doclint/check_public_api/test/diff-methods/api.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ class Foo {
1414
money$$money() {
1515
}
1616
}
17+
18+
export {Foo};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Foo {
2+
a = 42;
3+
b = 'hello';
4+
}
5+
export {Foo};

utils/doclint/check_public_api/test/diff-properties/foo.js

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class A {
2+
property1 = 1;
3+
_property2 = 2;
24
constructor(delegate) {
3-
this.property1 = 1;
4-
this._property2 = 2;
55
}
66

77
get getter() {
@@ -11,3 +11,5 @@ class A {
1111
async method(foo, bar) {
1212
}
1313
}
14+
15+
export {A};

utils/doclint/check_public_api/test/js-builder-inheritance/foo.js utils/doclint/check_public_api/test/js-builder-inheritance/api.ts

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ class B extends A {
1313
bar(override) {
1414
}
1515
}
16+
17+
export {A};
18+
export {B};

utils/doclint/check_public_api/test/test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let browserContext;
3434
let page;
3535

3636
beforeAll(async function() {
37-
browser = await playwright.launch();
37+
browser = await playwright.chromium.launch();
3838
page = await browser.newPage();
3939
});
4040

@@ -65,8 +65,9 @@ async function testLint(state, test) {
6565
});
6666

6767
const mdSources = await Source.readdir(dirPath, '.md');
68+
const tsSources = await Source.readdir(dirPath, '.ts');
6869
const jsSources = await Source.readdir(dirPath, '.js');
69-
const messages = await checkPublicAPI(page, mdSources, jsSources);
70+
const messages = await checkPublicAPI(page, mdSources, jsSources.concat(tsSources));
7071
const errors = messages.map(message => message.text);
7172
expect(errors.join('\n')).toBeGolden('result.txt');
7273
}
@@ -86,8 +87,9 @@ async function testJSBuilder(state, test) {
8687
const {expect} = new Matchers({
8788
toBeGolden: GoldenUtils.compare.bind(null, dirPath, dirPath)
8889
});
89-
const sources = await Source.readdir(dirPath, '.js');
90-
const {documentation} = await jsBuilder(sources);
90+
const jsSources = await Source.readdir(dirPath, '.js');
91+
const tsSources = await Source.readdir(dirPath, '.ts');
92+
const {documentation} = await jsBuilder.checkSources(jsSources.concat(tsSources));
9193
expect(serialize(documentation)).toBeGolden('result.txt');
9294
}
9395

0 commit comments

Comments
 (0)