#9 Unit tests

This commit is contained in:
Denys Vuika 2016-05-09 14:40:01 +01:00
parent 2f30ae687b
commit c5b2bc812c
19 changed files with 252 additions and 20 deletions

View File

@ -44,7 +44,7 @@ System.register(['angular2/core', './document-list'], function(exports_1, contex
// so that content children can access it // so that content children can access it
} }
ContentColumnList.prototype.registerColumn = function (column) { ContentColumnList.prototype.registerColumn = function (column) {
if (column) { if (this.documentList && column) {
this.documentList.columns.push(column); this.documentList.columns.push(column);
} }
}; };

View File

@ -1 +1 @@
{"version":3,"file":"content-column-list.js","sourceRoot":"","sources":["content-column-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAUH;gBACI,2BAAoB,YAA0B;oBAA1B,iBAAY,GAAZ,YAAY,CAAc;oBAC1C,sCAAsC;oBACtC,yCAAyC;gBAC7C,CAAC;gBAED,0CAAc,GAAd,UAAe,MAA0B;oBACrC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;wBACT,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC3C,CAAC;gBACL,CAAC;gBAdL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,iBAAiB;wBAC3B,QAAQ,EAAE,EAAE;qBACf,CAAC;;qCAAA;gBAYF,wBAAC;YAAD,CAAC,AAXD,IAWC;YAXD,iDAWC,CAAA"} {"version":3,"file":"content-column-list.js","sourceRoot":"","sources":["content-column-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAUH;gBACI,2BAAoB,YAA0B;oBAA1B,iBAAY,GAAZ,YAAY,CAAc;oBAC1C,sCAAsC;oBACtC,yCAAyC;gBAC7C,CAAC;gBAED,0CAAc,GAAd,UAAe,MAA0B;oBACrC,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,MAAM,CAAC,CAAC,CAAC;wBAC9B,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBAC3C,CAAC;gBACL,CAAC;gBAdL;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,iBAAiB;wBAC3B,QAAQ,EAAE,EAAE;qBACf,CAAC;;qCAAA;gBAYF,wBAAC;YAAD,CAAC,AAXD,IAWC;YAXD,iDAWC,CAAA"}

View File

@ -30,7 +30,7 @@ export class ContentColumnList {
} }
registerColumn(column: ContentColumnModel) { registerColumn(column: ContentColumnModel) {
if (column) { if (this.documentList && column) {
this.documentList.columns.push(column); this.documentList.columns.push(column);
} }
} }

View File

@ -54,7 +54,9 @@ System.register(['angular2/core', './content-column-list', './../models/content-
if (!model.srTitle && model.source === '$thumbnail') { if (!model.srTitle && model.source === '$thumbnail') {
model.srTitle = 'Thumbnail'; model.srTitle = 'Thumbnail';
} }
if (this.list) {
this.list.registerColumn(model); this.list.registerColumn(model);
}
}; };
__decorate([ __decorate([
core_1.Input(), core_1.Input(),

View File

@ -1 +1 @@
{"version":3,"file":"content-column.js","sourceRoot":"","sources":["content-column.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;;;;YAUH;gBAiBI,uBACY,IAAuB;oBAAvB,SAAI,GAAJ,IAAI,CAAmB;oBAfnC,UAAK,GAAW,EAAE,CAAC;gBAgBnB,CAAC;gBAED,gCAAQ,GAAR;oBACI,IAAI,KAAK,GAAG,IAAI,yCAAkB,EAAE,CAAC;oBACrC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;oBACzB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;oBAC7B,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;oBAC3B,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;oBAE/B,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,K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AAC,IAAI,CAAC,CAAC,CAAC;wBACZ,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC;gBAjCD;oBAAC,YAAK,EAAE;;4DAAA;gBAMR;oBAAC,YAAK,CAAC,UAAU,CAAC;;8DAAA;gBAGlB;oBAAC,YAAK,EAAE;;6DAAA;gBAGR;oBAAC,YAAK,CAAC,OAAO,CAAC;;+DAAA;gBAlBnB;oBAAC,gBAAS,CAAC;wBACP,QAAQ,EAAE,gBAAgB;wBAC1B,QAAQ,EAAE,EAAE;qBACf,CAAC;;iCAAA;gBAqCF,oBAAC;YAAD,CAAC,AApCD,IAoCC;YApCD,yCAoCC,CAAA"}

View File

@ -55,6 +55,8 @@ export class ContentColumn implements OnInit {
model.srTitle = 'Thumbnail'; model.srTitle = 'Thumbnail';
} }
if (this.list) {
this.list.registerColumn(model); this.list.registerColumn(model);
} }
}
} }

View File

@ -46,7 +46,7 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con
DocumentActionsService.prototype.getHandler = function (key) { DocumentActionsService.prototype.getHandler = function (key) {
if (key) { if (key) {
var lkey = key.toLowerCase(); var lkey = key.toLowerCase();
return this.handlers[lkey]; return this.handlers[lkey] || null;
} }
return null; return null;
}; };
@ -69,7 +69,7 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con
window.alert('standard document action 2'); window.alert('standard document action 2');
}; };
DocumentActionsService.prototype.download = function (obj) { DocumentActionsService.prototype.download = function (obj) {
if (obj && !obj.isFolder) { if (this._alfrescoService && obj && !obj.isFolder) {
var link = document.createElement('a'); var link = document.createElement('a');
document.body.appendChild(link); document.body.appendChild(link);
link.setAttribute('download', 'download'); link.setAttribute('download', 'download');

View File

@ -1 +1 @@
{"version":3,"file":"document-actions.service.js","sourceRoot":"","sources":["document-actions.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAOH;gBAGI,g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AC,WAAW,CAAC,IAAI,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC;gBAhDL;oBAAC,iBAAU,EAAE;;0CAAA;gBAiDb,6BAAC;YAAD,CAAC,AAhDD,IAgDC;YAhDD,2DAgDC,CAAA"}

View File

@ -30,7 +30,7 @@ export class DocumentActionsService {
getHandler(key: string): ContentActionHandler { getHandler(key: string): ContentActionHandler {
if (key) { if (key) {
let lkey = key.toLowerCase(); let lkey = key.toLowerCase();
return this.handlers[lkey]; return this.handlers[lkey] || null;
} }
return null; return null;
} }
@ -59,7 +59,7 @@ export class DocumentActionsService {
} }
private download(obj: any) { private download(obj: any) {
if (obj && !obj.isFolder) { if (this._alfrescoService && obj && !obj.isFolder) {
let link = document.createElement('a'); let link = document.createElement('a');
document.body.appendChild(link); document.body.appendChild(link);
link.setAttribute('download', 'download'); link.setAttribute('download', 'download');

View File

@ -44,7 +44,7 @@ System.register(['angular2/core'], function(exports_1, context_1) {
FolderActionsService.prototype.getHandler = function (key) { FolderActionsService.prototype.getHandler = function (key) {
if (key) { if (key) {
var lkey = key.toLowerCase(); var lkey = key.toLowerCase();
return this.handlers[lkey]; return this.handlers[lkey] || null;
} }
return null; return null;
}; };

View File

@ -1 +1 @@
{"version":3,"file":"folder-actions.service.js","sourceRoot":"","sources":["folder-actions.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;YAMH;gBAGI;oBAFQ,aAAQ,GAA4C,EAAE,CAAC;oBAG3D,qEAAqE;oBACrE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACjE,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACrE,CAAC;gBAED,yCAAU,GAAV,UAAW,GAAW;oBAClB,EAAE,CAAC,CAAC,G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AC;wBACN,IAAI,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;wBAC7B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;oBACvC,CAAC;oBACD,MAAM,CAAC,IAAI,CAAC;gBAChB,CAAC;gBAED,yCAAU,GAAV,UAAW,GAAW,EAAE,OAA6B;oBACjD,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACN,IAAI,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;wBAC7B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;oBAClC,CAAC;gBACL,CAAC;gBAEO,oDAAqB,GAA7B,UAA8B,QAAa;oBACvC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBAC7C,CAAC;gBAEO,oDAAqB,GAA7B,UAA8B,QAAa;oBACvC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBAC7C,CAAC;gBA/BL;oBAAC,iBAAU,EAAE;;wCAAA;gBAgCb,2BAAC;YAAD,CAAC,AA/BD,IA+BC;YA/BD,uDA+BC,CAAA"}

View File

@ -31,7 +31,7 @@ export class FolderActionsService {
getHandler(key: string): ContentActionHandler { getHandler(key: string): ContentActionHandler {
if (key) { if (key) {
let lkey = key.toLowerCase(); let lkey = key.toLowerCase();
return this.handlers[lkey]; return this.handlers[lkey] || null;
} }
return null; return null;
} }

View File

@ -0,0 +1,48 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
it,
describe,
expect,
beforeEach
} from 'angular2/testing';
import {DocumentList} from '../../src/components/document-list';
import {AlfrescoServiceMock} from '../assets/alfresco.service.mock';
import {ContentColumnList} from '../../src/components/content-column-list';
import {ContentColumnModel} from '../../src/models/content-column.model';
describe('ContentColumnList', () => {
let documentList: DocumentList;
let columnList: ContentColumnList;
beforeEach(() => {
let alfrescoServiceMock = new AlfrescoServiceMock();
documentList = new DocumentList(alfrescoServiceMock);
columnList = new ContentColumnList(documentList);
});
it('should register column within parent document list', () => {
expect(documentList.columns.length).toBe(0);
columnList.registerColumn(new ContentColumnModel());
expect(documentList.columns.length).toBe(1);
});
});

View File

@ -0,0 +1,79 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
it,
describe,
expect,
beforeEach
} from 'angular2/testing';
import {DocumentList} from '../../src/components/document-list';
import {ContentColumn} from '../../src/components/content-column';
import {AlfrescoServiceMock} from '../assets/alfresco.service.mock';
import {ContentColumnList} from '../../src/components/content-column-list';
describe('ContentColumn', () => {
let documentList: DocumentList;
let columnList: ContentColumnList;
beforeEach(() => {
let alfrescoServiceMock = new AlfrescoServiceMock();
documentList = new DocumentList(alfrescoServiceMock);
columnList = new ContentColumnList(documentList);
});
it('should register model within parent column list', () => {
spyOn(columnList, 'registerColumn').and.callThrough();
let column = new ContentColumn(columnList);
column.ngOnInit();
expect(columnList.registerColumn).toHaveBeenCalled();
});
it('should setup model properties during registration', () => {
let column = new ContentColumn(columnList);
column.title = '<title>';
column.srTitle = '<sr-title>';
column.source = '<source>';
column.cssClass = '<css-class>';
column.ngOnInit();
expect(documentList.columns.length).toBe(1);
let model = documentList.columns[0];
expect(model.title).toBe(column.title);
expect(model.srTitle).toBe(column.srTitle);
expect(model.source).toBe(column.source);
expect(model.cssClass).toBe(column.cssClass);
});
it('should setup screen reader title for thumbnail column', () => {
let column = new ContentColumn(columnList);
column.source = '$thumbnail';
column.ngOnInit();
expect(documentList.columns.length).toBe(1);
let model = documentList.columns[0];
expect(model.srTitle).toBe('Thumbnail');
});
});

View File

@ -18,7 +18,8 @@
import { import {
it, it,
describe, describe,
expect expect,
beforeEach
} from 'angular2/testing'; } from 'angular2/testing';
import {DocumentList} from '../../src/components/document-list'; import {DocumentList} from '../../src/components/document-list';
import {ContentColumnModel} from '../../src/models/content-column.model'; import {ContentColumnModel} from '../../src/models/content-column.model';
@ -26,7 +27,7 @@ import {AlfrescoServiceMock} from '../assets/alfresco.service.mock';
import {DocumentEntity} from '../../src/models/document-library.model'; import {DocumentEntity} from '../../src/models/document-library.model';
import {ContentActionModel} from '../../src/models/content-action.model'; import {ContentActionModel} from '../../src/models/content-action.model';
describe('document-list', () => { describe('DocumentList', () => {
let alfrescoServiceMock: AlfrescoServiceMock; let alfrescoServiceMock: AlfrescoServiceMock;
let documentList: DocumentList; let documentList: DocumentList;
@ -54,7 +55,8 @@ describe('document-list', () => {
let column: ContentColumnModel = { let column: ContentColumnModel = {
title: 'title', title: 'title',
source: 'source', source: 'source',
cssClass: 'css' cssClass: 'css',
srTitle: ''
}; };
documentList.columns.push(column); documentList.columns.push(column);

View File

@ -37,8 +37,11 @@
// #3. Import the spec file explicitly // #3. Import the spec file explicitly
Promise.all([ Promise.all([
System.import('test/components/document-list.spec')/*, System.import('test/components/document-list.spec'),
System.import('app/my-uppercase.pipe.spec')*/ System.import('test/components/content-column-list.spec'),
System.import('test/components/content-column.spec'),
System.import('test/services/folder-actions.service.spec'),
System.import('test/services/document-actions.service.spec')
]) ])
// #4. wait for all imports to load ... // #4. wait for all imports to load ...
// then re-execute `window.onload` which // then re-execute `window.onload` which

View File

@ -0,0 +1,57 @@
/**
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {
it,
describe,
expect,
beforeEach
} from 'angular2/testing';
import {ContentActionHandler} from '../../src/models/content-action.model';
import {DocumentActionsService} from '../../src/services/document-actions.service';
import {AlfrescoServiceMock} from '../assets/alfresco.service.mock';
describe('DocumentActionsService', () => {
let service: DocumentActionsService;
beforeEach(() => {
let alfrescoServiceMock = new AlfrescoServiceMock();
service = new DocumentActionsService(alfrescoServiceMock);
});
it('should register default download action', () => {
expect(service.getHandler('download')).not.toBeNull();
});
it('should register custom action handler', () => {
var handler: ContentActionHandler = function (obj: any) {};
service.setHandler('<key>', handler);
expect(service.getHandler('<key>')).toBe(handler);
});
it('should not find handler that is not registered', () => {
expect(service.getHandler('<missing>')).toBeNull();
});
it('should be case insensitive for keys', () => {
var handler: ContentActionHandler = function (obj: any) {};
service.setHandler('<key>', handler);
expect(service.getHandler('<KEY>')).toBe(handler);
});
});

View File

@ -15,3 +15,38 @@
* limitations under the License. * limitations under the License.
*/ */
import {
it,
describe,
expect,
beforeEach
} from 'angular2/testing';
import {FolderActionsService} from '../../src/services/folder-actions.service';
import {ContentActionHandler} from '../../src/models/content-action.model';
describe('FolderActionsService', () => {
let service: FolderActionsService;
beforeEach(() => {
service = new FolderActionsService();
});
it('should register custom action handler', () => {
var handler: ContentActionHandler = function (obj: any) {};
service.setHandler('<key>', handler);
expect(service.getHandler('<key>')).toBe(handler);
});
it('should not find handler that is not registered', () => {
expect(service.getHandler('<missing>')).toBeNull();
});
it('should be case insensitive for keys', () => {
var handler: ContentActionHandler = function (obj: any) {};
service.setHandler('<key>', handler);
expect(service.getHandler('<KEY>')).toBe(handler);
});
});

View File

@ -14,7 +14,11 @@
"../node_modules/angular2/typings/browser.d.ts", "../node_modules/angular2/typings/browser.d.ts",
"../typings/main/ambient/jasmine/index.d.ts", "../typings/main/ambient/jasmine/index.d.ts",
"assets/alfresco.service.mock.ts", "assets/alfresco.service.mock.ts",
"components/document-list.spec.ts" "components/document-list.spec.ts",
"components/content-column-list.spec.ts",
"components/content-column.spec.ts",
"services/folder-actions.service.spec.ts",
"services/document-actions.service.spec.ts"
], ],
"exclude": [ "exclude": [
] ]