diff --git a/lib/core/context-menu/context-menu-holder.component.spec.ts b/lib/core/context-menu/context-menu-holder.component.spec.ts index 6206e25794..c7f33b6213 100644 --- a/lib/core/context-menu/context-menu-holder.component.spec.ts +++ b/lib/core/context-menu/context-menu-holder.component.spec.ts @@ -76,6 +76,7 @@ describe('ContextMenuHolderComponent', () => { component = fixture.componentInstance; contextMenuService = TestBed.get(ContextMenuService); + component.ngOnDestroy = () => {}; fixture.detectChanges(); }); diff --git a/lib/core/context-menu/context-menu-holder.component.ts b/lib/core/context-menu/context-menu-holder.component.ts index 1c03dfca74..1a3e20f13b 100644 --- a/lib/core/context-menu/context-menu-holder.component.ts +++ b/lib/core/context-menu/context-menu-holder.component.ts @@ -80,7 +80,7 @@ export class ContextMenuHolderComponent implements OnInit, OnDestroy { this.subscriptions.push( this.contextMenuService.show.subscribe((mouseEvent) => this.showMenu(mouseEvent.event, mouseEvent.obj)), - this.menuTrigger.onMenuOpen.subscribe(() => { + this.menuTrigger.menuOpened.subscribe(() => { const container = this.overlayContainer.getContainerElement(); if (container) { this.contextMenuListenerFn = this.renderer.listen(container, 'contextmenu', (contextmenuEvent: Event) => { @@ -90,7 +90,7 @@ export class ContextMenuHolderComponent implements OnInit, OnDestroy { this.menuElement = this.getContextMenuElement(); }), - this.menuTrigger.onMenuClose.subscribe(() => { + this.menuTrigger.menuClosed.subscribe(() => { this.menuElement = null; if (this.contextMenuListenerFn) { this.contextMenuListenerFn(); diff --git a/lib/core/context-menu/context-menu-overlay.service.spec.ts b/lib/core/context-menu/context-menu-overlay.service.spec.ts index 6f96d4e3f9..fb5a180559 100644 --- a/lib/core/context-menu/context-menu-overlay.service.spec.ts +++ b/lib/core/context-menu/context-menu-overlay.service.spec.ts @@ -53,7 +53,7 @@ describe('ContextMenuService', () => { ); }); - it('should should create a custom overlay', () => { + it('should create a custom overlay', () => { contextMenuOverlayService.open(overlayConfig); expect(document.querySelector('.test-panel')).not.toBe(null); diff --git a/lib/core/context-menu/context-menu.service.spec.ts b/lib/core/context-menu/context-menu.service.spec.ts deleted file mode 100644 index 2e705760a7..0000000000 --- a/lib/core/context-menu/context-menu.service.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -/*! - * @license - * Copyright 2019 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 { ContextMenuService } from './context-menu.service'; - -describe('ContextMenuService', () => { - - let service; - - beforeEach(() => { - service = new ContextMenuService(); - }); - - it('should setup default show subject', () => { - expect(service.show).toBeDefined(); - }); - -}); diff --git a/lib/core/form/components/widgets/content/content.widget.spec.ts b/lib/core/form/components/widgets/content/content.widget.spec.ts index 6703d5d8d1..9504b7b2e5 100644 --- a/lib/core/form/components/widgets/content/content.widget.spec.ts +++ b/lib/core/form/components/widgets/content/content.widget.spec.ts @@ -42,7 +42,7 @@ describe('ContentWidgetComponent', () => { function createFakeImageBlob() { const data = atob('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=='); - return new Blob([data], {type: 'image/png'}); + return new Blob([data], { type: 'image/png' }); } function createFakePdfBlob(): Blob { @@ -60,7 +60,7 @@ describe('ContentWidgetComponent', () => { 'CjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAw' + 'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' + 'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G'); - return new Blob([pdfData], {type: 'application/pdf'}); + return new Blob([pdfData], { type: 'application/pdf' }); } setupTestBed({ @@ -165,7 +165,7 @@ describe('ContentWidgetComponent', () => { const contentId = 1; const change = new SimpleChange(null, contentId, true); - component.ngOnChanges({'id': change}); + component.ngOnChanges({ 'id': change }); jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, @@ -193,7 +193,7 @@ describe('ContentWidgetComponent', () => { const contentId = 1; const change = new SimpleChange(null, contentId, true); - component.ngOnChanges({'id': change}); + component.ngOnChanges({ 'id': change }); component.contentLoaded.subscribe((res) => { fixture.detectChanges(); @@ -250,6 +250,8 @@ describe('ContentWidgetComponent', () => { thumbnailStatus: 'created' }); + component.content.thumbnailUrl = '/alfresco-logo.svg'; + component.contentClick.subscribe((content) => { expect(content.contentBlob).toBe(blob); expect(content.mimeType).toBe('application/pdf'); @@ -284,6 +286,8 @@ describe('ContentWidgetComponent', () => { thumbnailStatus: 'created' }); + component.content.thumbnailUrl = '/alfresco-logo.svg'; + fixture.detectChanges(); const downloadButton: any = element.querySelector('#download'); downloadButton.click(); diff --git a/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts b/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts index 18540602b5..a58ab7195c 100644 --- a/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts +++ b/lib/core/form/components/widgets/date-time/date-time.widget.spec.ts @@ -50,7 +50,7 @@ describe('DateTimeWidgetComponent', () => { }); it('should setup min value for date picker', () => { - const minValue = '1982-03-13T10:00Z'; + const minValue = '1982-03-13T10:00:000Z'; widget.field = new FormFieldModel(null, { id: 'date-id', name: 'date-name', @@ -77,7 +77,7 @@ describe('DateTimeWidgetComponent', () => { }); it('should setup max value for date picker', () => { - const maxValue = '1982-03-13T10:00Z'; + const maxValue = '1982-03-13T10:00:000Z'; widget.field = new FormFieldModel(null, { maxValue: maxValue }); @@ -93,14 +93,14 @@ describe('DateTimeWidgetComponent', () => { const field = new FormFieldModel(new FormModel(), { id: 'date-field-id', name: 'date-name', - value: '9-12-9999 10:00 AM', + value: '09-12-9999 10:00 AM', type: 'datetime', readOnly: 'false' }); widget.field = field; - widget.onDateChanged({ value: moment('13-03-1982 10:00 AM') }); + widget.onDateChanged({ value: moment('2008-09-15T15:53:00') }); expect(widget.onFieldChanged).toHaveBeenCalledWith(field); }); diff --git a/lib/core/form/components/widgets/people/people.widget.spec.ts b/lib/core/form/components/widgets/people/people.widget.spec.ts index 44ed1b36a7..1f7d0c6cc9 100644 --- a/lib/core/form/components/widgets/people/people.widget.spec.ts +++ b/lib/core/form/components/widgets/people/people.widget.spec.ts @@ -49,8 +49,12 @@ describe('PeopleWidgetComponent', () => { formService = TestBed.get(FormService); translationService = TestBed.get(TranslateService); - spyOn(translationService, 'instant').and.callFake((key) => { return key; }); - spyOn(translationService, 'get').and.callFake((key) => { return of(key); }); + spyOn(translationService, 'instant').and.callFake((key) => { + return key; + }); + spyOn(translationService, 'get').and.callFake((key) => { + return of(key); + }); element = fixture.nativeElement; widget = fixture.componentInstance; @@ -143,7 +147,14 @@ describe('PeopleWidgetComponent', () => { expect(widget.groupId).toBe(''); }); - it('should display involved user in task form', async() => { + it('should display involved user in task form', async () => { + spyOn(formService, 'getWorkflowUsers').and.returnValue( + new Observable((observer) => { + observer.next(null); + observer.complete(); + }) + ); + widget.field.value = new UserProcessModel({ id: 'people-id', firstName: 'John', @@ -180,8 +191,10 @@ describe('PeopleWidgetComponent', () => { element = fixture.nativeElement; })); - afterEach(() => { - fixture.destroy(); + afterAll(() => { + if (fixture) { + fixture.destroy(); + } TestBed.resetTestingModule(); }); @@ -243,7 +256,7 @@ describe('PeopleWidgetComponent', () => { }); })); - it('should emit peopleSelected if option is valid', async() => { + it('should emit peopleSelected if option is valid', async () => { const selectEmitSpy = spyOn(widget.peopleSelected, 'emit'); const peopleHTMLElement: HTMLInputElement = element.querySelector('input'); peopleHTMLElement.focus(); diff --git a/lib/core/karma.conf.js b/lib/core/karma.conf.js index 47c44d0143..8db34eafad 100644 --- a/lib/core/karma.conf.js +++ b/lib/core/karma.conf.js @@ -8,16 +8,21 @@ module.exports = function (config) { files: [ {pattern: 'node_modules/core-js/client/core.js', included: true, watched: false}, {pattern: 'node_modules/tslib/tslib.js', included: true, watched: false}, + {pattern: 'node_modules/hammerjs/hammer.min.js', included: true, watched: false}, {pattern: 'node_modules/hammerjs/hammer.min.js.map', included: false, watched: false}, // pdf-js {pattern: 'node_modules/pdfjs-dist/build/pdf.js.map', included: false, watched: false}, {pattern: 'node_modules/pdfjs-dist/build/pdf.js', included: true, watched: false}, + {pattern: 'node_modules/pdfjs-dist/build/pdf.worker.js', included: true, watched: false, served: true}, {pattern: 'node_modules/pdfjs-dist/build/pdf.worker.js.map', included: false, watched: false}, {pattern: 'node_modules/pdfjs-dist/build/pdf.worker.min.js', included: true, watched: false, served: true}, + {pattern: 'node_modules/pdfjs-dist/web/pdf_viewer.js', included: true, watched: false}, + {pattern: 'node_modules/pdfjs-dist/web/pdf_viewer.js.map', served: true, included: false, watched: false}, + { pattern: 'node_modules/@angular/material/prebuilt-themes/indigo-pink.css', included: true, @@ -47,6 +52,7 @@ module.exports = function (config) { '/pdf.worker.min.js' :'/base/node_modules/pdfjs-dist/build/pdf.worker.min.js', '/pdf.worker.js' :'/base/node_modules/pdfjs-dist/build/pdf.worker.js', '/fake-url-file.png' :'/base/lib/core/assets/images/logo.png', + '/logo.png' :'/base/lib/core/assets/images/logo.png', '/alfresco-logo.svg' :'/base/lib/core/assets/images/alfresco-logo.svg', '/assets/images/': '/base/lib/core/assets/images/', '/assets/images/ecm-background.png': '/base/lib/core/assets/images/ecm-background.png', diff --git a/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.spec.ts b/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.spec.ts index 4634444800..41eb53d423 100644 --- a/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.spec.ts +++ b/lib/core/layout/components/sidebar-action/sidebar-action-menu.component.spec.ts @@ -21,6 +21,7 @@ import { MaterialModule } from '../../../material.module'; import { SidebarActionMenuComponent } from './sidebar-action-menu.component'; import { setupTestBed } from '../../../testing/setupTestBed'; import { CoreTestingModule } from '../../../testing/core.testing.module'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; describe('SidebarActionMenuComponent', () => { let element: HTMLElement; @@ -91,7 +92,8 @@ describe('Custom SidebarActionMenuComponent', () => { CustomSidebarActionMenuComponent ], imports: [ - MaterialModule + MaterialModule, + NoopAnimationsModule ] });