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: enforce sorting of the public_api_spec #8950

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 14 additions & 6 deletions tools/public_api_guard/public_api_spec.ts
Expand Up @@ -898,9 +898,9 @@ const COMMON = [
'NgForm.ngSubmit:any',
'NgForm.onSubmit():boolean',
'NgForm.path:string[]',
'NgForm.submitted:boolean',
'NgForm.removeControl(dir:NgControl):void',
'NgForm.removeControlGroup(dir:NgControlGroup):void',
'NgForm.submitted:boolean',
'NgForm.updateModel(dir:NgControl, value:any):void',
'NgFormControl',
'NgFormControl.asyncValidator:AsyncValidatorFn',
Expand Down Expand Up @@ -928,9 +928,9 @@ const COMMON = [
'NgFormModel.ngSubmit:any',
'NgFormModel.onSubmit():boolean',
'NgFormModel.path:string[]',
'NgFormModel.submitted:boolean',
'NgFormModel.removeControl(dir:NgControl):void',
'NgFormModel.removeControlGroup(dir:NgControlGroup):any',
'NgFormModel.submitted:boolean',
'NgFormModel.updateModel(dir:NgControl, value:any):void',
'NgIf',
'NgIf.constructor(_viewContainer:ViewContainerRef, _templateRef:TemplateRef<Object>)',
Expand Down Expand Up @@ -1882,8 +1882,8 @@ const HTTP = [
'Response.status:number',
'Response.statusText:string',
'Response.text():string',
'Response.totalBytes:number',
'Response.toString():string',
'Response.totalBytes:number',
'Response.type:ResponseType',
'Response.url:string',
'ResponseOptions',
Expand Down Expand Up @@ -1947,13 +1947,14 @@ const HTTP_TESTING = [
'MockConnection.mockDownload(res:Response):any',
'MockConnection.mockError(err?:Error):any',
'MockConnection.mockRespond(res:Response):any',
'MockConnection.mockRespond(res:Response):any',
'MockConnection.readyState:ReadyState',
'MockConnection.request:Request',
'MockConnection.response:ReplaySubject<Response>',
];


fdescribe('public API', () => {
describe('public API', () => {
check('@angular/core/index.ts', CORE);
check('@angular/core/testing.ts', CORE_TESTING);
check('@angular/common/index.ts', COMMON);
Expand All @@ -1971,16 +1972,23 @@ fdescribe('public API', () => {
});

function check(file: string, expected: string[]) {
it('should check' + file, () => checkPublicApi(file, expected));
it('should check ' + file, () => checkPublicApi(file, expected));
}

function checkPublicApi(file: string, expected: string[]) {
const sortedActual = publicApi('modules/' + file).sort();
const sortedExpected = expected.sort();
const sortedExpected = expected.slice().sort();

const unsorted = expected.find((element, index) => element !== sortedExpected[index]);
const missing = sortedActual.filter((i) => sortedExpected.indexOf(i) < 0);
const extra = sortedExpected.filter((i) => sortedActual.indexOf(i) < 0);

// console.log(sortedActual.join('\',\n \''));
if (unsorted) {
fail(`The array of expected APIs is incorrectly sorted starting at element:\n ${unsorted}`);
}


if (missing.length > 0) {
console.log('=================================================================');
console.log('=================================================================');
Expand Down