test: enforce sorting of the public_api_spec

Closes #8950
This commit is contained in:
Igor Minar 2016-06-01 12:34:59 -07:00
parent 602836800b
commit d38d375fa6
1 changed files with 14 additions and 6 deletions

View File

@ -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',
@ -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>)',
@ -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',
@ -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);
@ -1976,11 +1977,18 @@ function check(file: string, expected: string[]) {
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('=================================================================');