diff --git a/ng2-components/ng2-alfresco-datatable/karma.conf.js b/ng2-components/ng2-alfresco-datatable/karma.conf.js index 8f3adc54b4..94b9ff4994 100644 --- a/ng2-components/ng2-alfresco-datatable/karma.conf.js +++ b/ng2-components/ng2-alfresco-datatable/karma.conf.js @@ -96,7 +96,7 @@ module.exports = function (config) { // Source files that you wanna generate coverage for. // Do not include tests or libraries (these files will be instrumented by Istanbul) preprocessors: { - 'dist/**/!(*spec|index|*mock|*model).js': 'coverage' + 'dist/**/!(*spec|index|*mock|*model|*interface).js': 'coverage' }, coverageReporter: { diff --git a/ng2-components/ng2-alfresco-datatable/src/components/datatable/no-content-template.component.spec.ts b/ng2-components/ng2-alfresco-datatable/src/components/datatable/no-content-template.component.spec.ts new file mode 100644 index 0000000000..83fafdf962 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/components/datatable/no-content-template.component.spec.ts @@ -0,0 +1,41 @@ +/*! + * @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 { NoContentTemplateComponent } from '../datatable/no-content-template.component'; +import { Injector } from '@angular/core'; +import { getTestBed, TestBed } from '@angular/core/testing'; +import { DataTableComponent } from './datatable.component'; + +describe('NoContentTemplateComponent', () => { + let injector: Injector; + let noContentTemplateComponent: NoContentTemplateComponent; + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + NoContentTemplateComponent, + DataTableComponent + ] + }); + injector = getTestBed(); + noContentTemplateComponent = injector.get(NoContentTemplateComponent); + }); + + it('is defined', () => { + expect(noContentTemplateComponent).toBeDefined(); + }); +}); diff --git a/ng2-components/ng2-alfresco-datatable/src/components/pagination/index.ts b/ng2-components/ng2-alfresco-datatable/src/components/pagination/index.ts index 9e25a61495..1b1e7e47b6 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/pagination/index.ts +++ b/ng2-components/ng2-alfresco-datatable/src/components/pagination/index.ts @@ -15,5 +15,5 @@ * limitations under the License. */ -export * from './pagination-provider'; +export * from './paginationProvider.interface'; export * from './pagination.component'; diff --git a/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.spec.ts b/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.spec.ts new file mode 100644 index 0000000000..6266faa761 --- /dev/null +++ b/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.spec.ts @@ -0,0 +1,82 @@ +/*! + * @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 { PaginationComponent } from '../pagination/pagination.component'; +import { PaginationProvider, DataLoadedEventEmitter} from '../pagination/paginationProvider.interface'; +import { Injector } from '@angular/core'; +import { getTestBed, TestBed} from '@angular/core/testing'; + +class CustomPaginationProvider implements PaginationProvider { + skipCount: number = 0; + dataLoaded: DataLoadedEventEmitter; + count: number = 200; + hasMoreItems: boolean = false; + maxItems: number = 20; +} + +describe('PaginationComponent', () => { + let injector: Injector; + let paginationComponent: PaginationComponent; + + beforeEach(() => { + TestBed.configureTestingModule({ + providers: [ + PaginationComponent + ] + }); + injector = getTestBed(); + paginationComponent = injector.get(PaginationComponent); + paginationComponent.provider = new CustomPaginationProvider(); + }); + + it('is defined', () => { + expect(paginationComponent).toBeDefined(); + }); + + it('page size', () => { + expect(paginationComponent.pageSize).toBe(20); + }); + + it('set page size', () => { + paginationComponent.pageSize = 100; + expect(paginationComponent.pageSize).toBe(100); + }); + + it('prevPageAvail', () => { + expect(paginationComponent.prevPageAvail).toBe(false); + }); + + it('nextPageAvail', () => { + expect(paginationComponent.nextPageAvail).toBe(false); + }); + + it('showNextPage', () => { + expect(paginationComponent.provider.skipCount).toBe(0); + paginationComponent.showNextPage(); + expect(paginationComponent.provider.skipCount).toBe(20); + }); + + it('showPrevPage', () => { + paginationComponent.provider.skipCount = 100; + paginationComponent.showPrevPage(); + expect(paginationComponent.provider.skipCount).toBe(80); + }); + + it('PaginationProvider', () => { + expect(paginationComponent.provider instanceof CustomPaginationProvider).toBeTruthy(); + }); +}); diff --git a/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.ts b/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.ts index 2daa0f1780..fdc0d233c6 100644 --- a/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.ts +++ b/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination.component.ts @@ -16,7 +16,7 @@ */ import { Component, Input, OnInit } from '@angular/core'; -import { PaginationProvider } from './pagination-provider'; +import { PaginationProvider } from './paginationProvider.interface'; @Component({ moduleId: module.id, diff --git a/ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination-provider.ts b/ng2-components/ng2-alfresco-datatable/src/components/pagination/paginationProvider.interface.ts similarity index 100% rename from ng2-components/ng2-alfresco-datatable/src/components/pagination/pagination-provider.ts rename to ng2-components/ng2-alfresco-datatable/src/components/pagination/paginationProvider.interface.ts