Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for API docs coverage changes #16910

Merged
merged 8 commits into from
Oct 14, 2018
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
blueprints/*/*files/**/*.js
node-tests/fixtures/**/*.js
docs/
/docs/
dist/
tmp/
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ module.exports = {
'tests/node/**/*.js',
'blueprints/**/*.js',
'bin/**/*.js',
'tests/docs/*.js',
'config/**/*.js',
'lib/**/*.js',
'server/**/*.js',
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ assets/bpm_libs.js
assets/bpm_styles.css
coverage
dist
docs
/docs
lib/*/tests/all.js
lib/*/tests/qunit*
lib/bundler/man
Expand Down
1 change: 1 addition & 0 deletions bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function codeQualityChecks() {
runChecker('node', [require.resolve('typescript/bin/tsc'), '--noEmit']),
runChecker('node', [require.resolve('tslint/bin/tslint'), '-p', 'tsconfig.json']),
runChecker('node', [require.resolve('eslint/bin/eslint'), '.']),
runChecker('node', [require.resolve('qunit/bin/qunit'), 'tests/docs/coverage-test.js']),
];
return Promise.all(checkers).then(function(results) {
results.forEach(result => {
Expand Down
65 changes: 65 additions & 0 deletions tests/docs/coverage-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* eslint-disable no-console */
'use strict';

const QUnit = require('qunit');
const test = QUnit.test;
const path = require('path');

QUnit.module('Docs coverage', function(hooks) {
let docs, expected;
hooks.before(function() {
if (!process.env.REUSE_DOCS) {
buildDocs();
}
docs = require(path.join(__dirname, '../../docs/data.json'));
expected = require('./expected');
});

QUnit.module('classitems', function(hooks) {
let docsItems, expectedItems;
hooks.before(function() {
docsItems = new Set(docs.classitems.map(item => item.name).filter(Boolean));
expectedItems = new Set(expected.classitems);
});

test('No missing classitems', function(assert) {
let missing = setDifference(expectedItems, docsItems);
assert.emptySet(
missing,
'If you have added new features, please update tests/docs/expected.js and confirm that any public properties are marked both @public and @static to be included in the Ember API Docs viewer.'
);
});

test('No extraneous classitems', function(assert) {
let extraneous = setDifference(docsItems, expectedItems);
assert.emptySet(
extraneous,
'If you intentionally removed a public API method, please udpate tests/docs/expected.js. Otherwise, documentation is missing, incorrectly formatted, or in a directory that is not watched by yuidoc. All files containing documentation must have a yuidoc class declaration.'
);
});
});
});

function buildDocs() {
let child = require('child_process');
child.execFileSync('node', [require.resolve('ember-cli/bin/ember'), 'ember-cli-yuidoc'], {
stdio: 'pipe',
});
}

function setDifference(setA, setB) {
let difference = new Set(setA);
for (var elem of setB) {
difference.delete(elem);
}
return difference;
}

QUnit.assert.emptySet = function assertEmptySet(value, message) {
this.pushResult({
result: value.size === 0,
actual: Array.from(value).sort(),
expected: [],
message: message,
});
};
Loading