From c5b2bc812c482d1e30176607a3d1981c1eb20f41 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Mon, 9 May 2016 14:40:01 +0100 Subject: [PATCH] #9 Unit tests --- .../src/components/content-column-list.js | 2 +- .../src/components/content-column-list.js.map | 2 +- .../src/components/content-column-list.ts | 2 +- .../src/components/content-column.js | 4 +- .../src/components/content-column.js.map | 2 +- .../src/components/content-column.ts | 4 +- .../src/services/document-actions.service.js | 4 +- .../services/document-actions.service.js.map | 2 +- .../src/services/document-actions.service.ts | 4 +- .../src/services/folder-actions.service.js | 2 +- .../services/folder-actions.service.js.map | 2 +- .../src/services/folder-actions.service.ts | 2 +- .../components/content-column-list.spec.ts | 48 +++++++++++ .../test/components/content-column.spec.ts | 79 +++++++++++++++++++ .../test/components/document-list.spec.ts | 8 +- .../ng2-alfresco-documentlist/test/index.html | 7 +- .../services/document-actions.service.spec.ts | 57 +++++++++++++ .../services/folder-actions.service.spec.ts | 35 ++++++++ .../test/tsconfig.json | 6 +- 19 files changed, 252 insertions(+), 20 deletions(-) create mode 100644 ng2-components/ng2-alfresco-documentlist/test/components/content-column-list.spec.ts create mode 100644 ng2-components/ng2-alfresco-documentlist/test/components/content-column.spec.ts create mode 100644 ng2-components/ng2-alfresco-documentlist/test/services/document-actions.service.spec.ts diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js index 41e35c9438..96d6fee1fa 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js @@ -44,7 +44,7 @@ System.register(['angular2/core', './document-list'], function(exports_1, contex // so that content children can access it } ContentColumnList.prototype.registerColumn = function (column) { - if (column) { + if (this.documentList && column) { this.documentList.columns.push(column); } }; diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js.map b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js.map index 42ad335fcd..c00bd59f55 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js.map +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.js.map @@ -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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.ts index 0ad9d62688..ad48474c11 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column-list.ts @@ -30,7 +30,7 @@ export class ContentColumnList { } registerColumn(column: ContentColumnModel) { - if (column) { + if (this.documentList && column) { this.documentList.columns.push(column); } } diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js index 0851eb3d4c..ed6cd83cce 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js @@ -54,7 +54,9 @@ System.register(['angular2/core', './content-column-list', './../models/content- if (!model.srTitle && model.source === '$thumbnail') { model.srTitle = 'Thumbnail'; } - this.list.registerColumn(model); + if (this.list) { + this.list.registerColumn(model); + } }; __decorate([ core_1.Input(), diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js.map b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js.map index be345dae57..511410ad0c 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js.map +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.js.map @@ -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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M,GAAG,IAAI,CAAC,MAAM,CAAC;oBAC3B,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;oBAE/B,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,KAAK,YAAY,CAAC,CAAC,CAAC;wBAClD,KAAK,CAAC,OAAO,GAAG,WAAW,CAAC;oBAChC,CAAC;oBAED,EAAE,CAAC,CAAC,IAAI,CAAC,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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts index 65a2d23ec6..cc62d35db2 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/components/content-column.ts @@ -55,6 +55,8 @@ export class ContentColumn implements OnInit { model.srTitle = 'Thumbnail'; } - this.list.registerColumn(model); + if (this.list) { + this.list.registerColumn(model); + } } } diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js index f7b0be49e7..c0bf009745 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js @@ -46,7 +46,7 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con DocumentActionsService.prototype.getHandler = function (key) { if (key) { var lkey = key.toLowerCase(); - return this.handlers[lkey]; + return this.handlers[lkey] || null; } return null; }; @@ -69,7 +69,7 @@ System.register(['angular2/core', './alfresco.service'], function(exports_1, con window.alert('standard document action 2'); }; DocumentActionsService.prototype.download = function (obj) { - if (obj && !obj.isFolder) { + if (this._alfrescoService && obj && !obj.isFolder) { var link = document.createElement('a'); document.body.appendChild(link); link.setAttribute('download', 'download'); diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map index e32a58a868..fbf975bc28 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.js.map @@ -1 +1 @@ -{"version":3,"file":"document-actions.service.js","sourceRoot":"","sources":["document-actions.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAOH;gBAGI,gCAAoB,gBAAiC;oBAAjC,qBAAgB,GAAhB,gBAAgB,CAAiB;oBAF7C,aAAQ,GAA4C,EAAE,CAAC;oBAG3D,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC/B,CAAC;gBAED,2CAAU,GAAV,UAAW,GAAW;oBAClB,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACN,IAAI,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;wBAC7B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC/B,CAAC;oBACD,MAAM,CAAC,IAAI,CAAC;gBAChB,CAAC;gBAED,2CAAU,GAAV,UAAW,GAAW,EAAE,OAA6B;oBACjD,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;wBACN,IAAI,IAAI,GAAG,GAAG,CAA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,EAAE;;0CAAA;gBAiDb,6BAAC;YAAD,CAAC,AAhDD,IAgDC;YAhDD,2DAgDC,CAAA"} \ No newline at end of file +{"version":3,"file":"document-actions.service.js","sourceRoot":"","sources":["document-actions.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;;;;;;;;;;;;;;;;;;;;;;;;YAOH;gBAGI,gCAAoB,gBAAiC;oBAAjC,qBAAgB,GAAhB,gBAAgB,CAAiB;oBAF7C,aAAQ,GAA4C,EAAE,CAAC;oBAG3D,IAAI,CAAC,mBAAmB,EAAE,CAAC;gBAC/B,CAAC;gBAED,2CAAU,GAAV,UAAW,GAAW;oBAClB,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;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,2CAAU,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,oDAAmB,GAA3B;oBACI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAErD,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;gBAEO,sDAAqB,GAA7B,UAA8B,GAAQ;oBAClC,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAC/C,CAAC;gBAEO,sDAAqB,GAA7B,UAA8B,GAAQ;oBAClC,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;gBAC/C,CAAC;gBAEO,yCAAQ,GAAhB,UAAiB,GAAQ;oBACrB,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;wBAChD,IAAI,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;wBACvC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;wBAChC,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;wBAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;wBACrD,IAAI,CAAC,KAAK,EAAE,CAAC;wBACb,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC;gBAhDL;oBAAC,iBAAU,EAAE;;0CAAA;gBAiDb,6BAAC;YAAD,CAAC,AAhDD,IAgDC;YAhDD,2DAgDC,CAAA"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts index 3dce46d9b4..d15ef780ad 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-actions.service.ts @@ -30,7 +30,7 @@ export class DocumentActionsService { getHandler(key: string): ContentActionHandler { if (key) { let lkey = key.toLowerCase(); - return this.handlers[lkey]; + return this.handlers[lkey] || null; } return null; } @@ -59,7 +59,7 @@ export class DocumentActionsService { } private download(obj: any) { - if (obj && !obj.isFolder) { + if (this._alfrescoService && obj && !obj.isFolder) { let link = document.createElement('a'); document.body.appendChild(link); link.setAttribute('download', 'download'); diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js index 7ae2b32bdd..6997fb6e9a 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js +++ b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js @@ -44,7 +44,7 @@ System.register(['angular2/core'], function(exports_1, context_1) { FolderActionsService.prototype.getHandler = function (key) { if (key) { var lkey = key.toLowerCase(); - return this.handlers[lkey]; + return this.handlers[lkey] || null; } return null; }; diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js.map b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js.map index 898f9f0cfc..34251d612c 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js.map +++ b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.js.map @@ -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,GAAG,CAAC,CAAC,CAAC;wBACN,IAAI,IAAI,GAAG,GAAG,CAAC,WAAW,EA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C;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"} \ No newline at end of file diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts index 7727598616..f364b6d6a8 100644 --- a/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts +++ b/ng2-components/ng2-alfresco-documentlist/src/services/folder-actions.service.ts @@ -31,7 +31,7 @@ export class FolderActionsService { getHandler(key: string): ContentActionHandler { if (key) { let lkey = key.toLowerCase(); - return this.handlers[lkey]; + return this.handlers[lkey] || null; } return null; } diff --git a/ng2-components/ng2-alfresco-documentlist/test/components/content-column-list.spec.ts b/ng2-components/ng2-alfresco-documentlist/test/components/content-column-list.spec.ts new file mode 100644 index 0000000000..600984cdc3 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/test/components/content-column-list.spec.ts @@ -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); + }); + +}); diff --git a/ng2-components/ng2-alfresco-documentlist/test/components/content-column.spec.ts b/ng2-components/ng2-alfresco-documentlist/test/components/content-column.spec.ts new file mode 100644 index 0000000000..192fbc854a --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/test/components/content-column.spec.ts @@ -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 = ''; + 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'); + }); + +}); diff --git a/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts b/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts index 3b213b0b53..3298376ead 100644 --- a/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/test/components/document-list.spec.ts @@ -18,7 +18,8 @@ import { it, describe, - expect + expect, + beforeEach } from 'angular2/testing'; import {DocumentList} from '../../src/components/document-list'; 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 {ContentActionModel} from '../../src/models/content-action.model'; -describe('document-list', () => { +describe('DocumentList', () => { let alfrescoServiceMock: AlfrescoServiceMock; let documentList: DocumentList; @@ -54,7 +55,8 @@ describe('document-list', () => { let column: ContentColumnModel = { title: 'title', source: 'source', - cssClass: 'css' + cssClass: 'css', + srTitle: '' }; documentList.columns.push(column); diff --git a/ng2-components/ng2-alfresco-documentlist/test/index.html b/ng2-components/ng2-alfresco-documentlist/test/index.html index 4eb214ae28..5f5baff899 100644 --- a/ng2-components/ng2-alfresco-documentlist/test/index.html +++ b/ng2-components/ng2-alfresco-documentlist/test/index.html @@ -37,8 +37,11 @@ // #3. Import the spec file explicitly Promise.all([ - System.import('test/components/document-list.spec')/*, - System.import('app/my-uppercase.pipe.spec')*/ + System.import('test/components/document-list.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 ... // then re-execute `window.onload` which diff --git a/ng2-components/ng2-alfresco-documentlist/test/services/document-actions.service.spec.ts b/ng2-components/ng2-alfresco-documentlist/test/services/document-actions.service.spec.ts new file mode 100644 index 0000000000..c0b1fef9a7 --- /dev/null +++ b/ng2-components/ng2-alfresco-documentlist/test/services/document-actions.service.spec.ts @@ -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); + + }); +}); diff --git a/ng2-components/ng2-alfresco-documentlist/test/services/folder-actions.service.spec.ts b/ng2-components/ng2-alfresco-documentlist/test/services/folder-actions.service.spec.ts index c764123b97..6d6293cd99 100644 --- a/ng2-components/ng2-alfresco-documentlist/test/services/folder-actions.service.spec.ts +++ b/ng2-components/ng2-alfresco-documentlist/test/services/folder-actions.service.spec.ts @@ -15,3 +15,38 @@ * 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); + + }); + +}); diff --git a/ng2-components/ng2-alfresco-documentlist/test/tsconfig.json b/ng2-components/ng2-alfresco-documentlist/test/tsconfig.json index 9f01d6c97c..288a503eb7 100644 --- a/ng2-components/ng2-alfresco-documentlist/test/tsconfig.json +++ b/ng2-components/ng2-alfresco-documentlist/test/tsconfig.json @@ -14,7 +14,11 @@ "../node_modules/angular2/typings/browser.d.ts", "../typings/main/ambient/jasmine/index.d.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": [ ]