diff --git a/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts b/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts index 11acdb8841..da0ac61d83 100644 --- a/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts +++ b/lib/content-services/content-node-selector/name-location-cell/name-location-cell.component.spec.ts @@ -15,23 +15,22 @@ * limitations under the License. */ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { NameLocationCellComponent } from './name-location-cell.component'; import { By } from '@angular/platform-browser'; import { DataRow } from '@alfresco/adf-core'; +import { setupTestBed } from '../../../core/testing/setupTestBed'; describe('NameLocationCellComponent', () => { let component: NameLocationCellComponent; let fixture: ComponentFixture; let rowData: DataRow; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - NameLocationCellComponent - ] - }).compileComponents(); - })); + setupTestBed({ + declarations: [ + NameLocationCellComponent + ] + }); beforeEach(() => { fixture = TestBed.createComponent(NameLocationCellComponent); diff --git a/lib/content-services/upload/components/file-uploading-list-row.component.spec.ts b/lib/content-services/upload/components/file-uploading-list-row.component.spec.ts index fe6a28043e..4b367deb88 100644 --- a/lib/content-services/upload/components/file-uploading-list-row.component.spec.ts +++ b/lib/content-services/upload/components/file-uploading-list-row.component.spec.ts @@ -19,19 +19,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FileModel, CoreModule, FileUploadOptions, FileUploadStatus } from '@alfresco/adf-core'; import { UploadModule } from '../upload.module'; import { FileUploadingListRowComponent } from './file-uploading-list-row.component'; +import { setupTestBed } from '../../../core/testing/setupTestBed'; describe('FileUploadingListRowComponent', () => { let fixture: ComponentFixture; let component: FileUploadingListRowComponent; const file = new FileModel( { name: 'fake-name' }); - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - CoreModule.forRoot(), - UploadModule - ] - }).compileComponents(); + setupTestBed({ + imports: [ + CoreModule.forRoot(), + UploadModule + ] }); beforeEach(() => { diff --git a/lib/core/card-view/services/card-view-update.service.spec.ts b/lib/core/card-view/services/card-view-update.service.spec.ts index a572b380a2..88472cd28a 100644 --- a/lib/core/card-view/services/card-view-update.service.spec.ts +++ b/lib/core/card-view/services/card-view-update.service.spec.ts @@ -18,6 +18,7 @@ import { async, TestBed } from '@angular/core/testing'; import { CardViewBaseItemModel } from '../models/card-view-baseitem.model'; import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service'; +import { setupTestBed } from '../../testing/setupTestBed'; describe('CardViewUpdateService', () => { @@ -58,13 +59,11 @@ describe('CardViewUpdateService', () => { clickable: false }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - providers: [ - CardViewUpdateService - ] - }).compileComponents(); - })); + setupTestBed({ + providers: [ + CardViewUpdateService + ] + }); beforeEach(() => { cardViewUpdateService = TestBed.get(CardViewUpdateService); diff --git a/lib/core/clipboard/clipboard.service.spec.ts b/lib/core/clipboard/clipboard.service.spec.ts index 8c97214ddf..3760b5f7c9 100644 --- a/lib/core/clipboard/clipboard.service.spec.ts +++ b/lib/core/clipboard/clipboard.service.spec.ts @@ -26,26 +26,25 @@ import { AppConfigServiceMock } from '../mock/app-config.service.mock'; import { HttpClientModule } from '@angular/common/http'; import { MatSnackBarModule } from '@angular/material'; import { TranslationMock } from '@alfresco/adf-core'; +import { setupTestBed } from '../testing/setupTestBed'; describe('ClipboardService', () => { let clipboardService: ClipboardService; let notificationService: NotificationService; let inputElement; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - ClipboardModule, - HttpClientModule, - MatSnackBarModule - ], - providers: [ - LogService, - { provide: TranslationService, useClass: TranslationMock }, - { provide: AppConfigService, useClass: AppConfigServiceMock }, - NotificationService - ] - }); + setupTestBed({ + imports: [ + ClipboardModule, + HttpClientModule, + MatSnackBarModule + ], + providers: [ + LogService, + { provide: TranslationService, useClass: TranslationMock }, + { provide: AppConfigService, useClass: AppConfigServiceMock }, + NotificationService + ] }); beforeEach(() => { diff --git a/lib/core/comments/comment-list.component.spec.ts b/lib/core/comments/comment-list.component.spec.ts index fd23166c78..4fc4180482 100644 --- a/lib/core/comments/comment-list.component.spec.ts +++ b/lib/core/comments/comment-list.component.spec.ts @@ -117,10 +117,10 @@ describe('CommentListComponent', () => { beforeEach(async(() => { ecmUserService = TestBed.get(EcmUserService); - spyOn(ecmUserService, 'getUserProfileImage').and.returnValue('content-user-image'); + spyOn(ecmUserService, 'getUserProfileImage').and.returnValue('alfresco-logo.svg'); peopleProcessService = TestBed.get(PeopleProcessService); - spyOn(peopleProcessService, 'getUserImage').and.returnValue('process-user-image'); + spyOn(peopleProcessService, 'getUserImage').and.returnValue('alfresco-logo.svg'); fixture = TestBed.createComponent(CommentListComponent); commentList = fixture.componentInstance; @@ -259,7 +259,7 @@ describe('CommentListComponent', () => { fixture.whenStable().then(() => { const elements = fixture.nativeElement.querySelectorAll('.adf-people-img'); expect(elements.length).toBe(1); - expect(fixture.nativeElement.getElementsByClassName('adf-people-img')[0].src).toContain('content-user-image'); + expect(fixture.nativeElement.getElementsByClassName('adf-people-img')[0].src).toContain('alfresco-logo.svg'); }); })); @@ -270,7 +270,7 @@ describe('CommentListComponent', () => { fixture.whenStable().then(() => { const elements = fixture.nativeElement.querySelectorAll('.adf-people-img'); expect(elements.length).toBe(1); - expect(fixture.nativeElement.getElementsByClassName('adf-people-img')[0].src).toContain('process-user-image'); + expect(fixture.nativeElement.getElementsByClassName('adf-people-img')[0].src).toContain('alfresco-logo.svg'); }); })); 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 e64cef1407..6206e25794 100644 --- a/lib/core/context-menu/context-menu-holder.component.spec.ts +++ b/lib/core/context-menu/context-menu-holder.component.spec.ts @@ -23,6 +23,7 @@ import { ContextMenuModule } from './context-menu.module'; import { ContextMenuService } from './context-menu.service'; import { CoreModule } from '../core.module'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { setupTestBed } from '../testing/setupTestBed'; describe('ContextMenuHolderComponent', () => { let fixture: ComponentFixture; @@ -52,25 +53,25 @@ describe('ContextMenuHolderComponent', () => { }) }; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - NoopAnimationsModule, - CoreModule.forRoot(), - ContextMenuModule - ], - providers: [ - { - provide: OverlayContainer, - useValue: overlayContainer - }, - { - provide: ViewportRuler, - useValue: getViewportRect - } - ] - }); + setupTestBed({ + imports: [ + NoopAnimationsModule, + CoreModule.forRoot(), + ContextMenuModule + ], + providers: [ + { + provide: OverlayContainer, + useValue: overlayContainer + }, + { + provide: ViewportRuler, + useValue: getViewportRect + } + ] + }); + beforeEach(() => { fixture = TestBed.createComponent(ContextMenuHolderComponent); component = fixture.componentInstance; contextMenuService = TestBed.get(ContextMenuService); 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 13df9279a1..6f96d4e3f9 100644 --- a/lib/core/context-menu/context-menu-overlay.service.spec.ts +++ b/lib/core/context-menu/context-menu-overlay.service.spec.ts @@ -15,12 +15,13 @@ * limitations under the License. */ -import { TestBed } from '@angular/core/testing'; import { Overlay } from '@angular/cdk/overlay'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { CoreTestingModule } from '../testing/core.testing.module'; import { ContextMenuOverlayService } from './context-menu-overlay.service'; import { Injector } from '@angular/core'; +import { setupTestBed } from '../testing/setupTestBed'; +import { TestBed } from '@angular/core/testing'; describe('ContextMenuService', () => { let contextMenuOverlayService: ContextMenuOverlayService; @@ -34,12 +35,12 @@ describe('ContextMenuService', () => { } }; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [NoopAnimationsModule, CoreTestingModule], - providers: [ Overlay ] - }); + setupTestBed({ + imports: [NoopAnimationsModule, CoreTestingModule], + providers: [ Overlay ] + }); + beforeEach(() => { overlay = TestBed.get(Overlay); injector = TestBed.get(Injector); }); diff --git a/lib/core/context-menu/context-menu.spec.ts b/lib/core/context-menu/context-menu.spec.ts index 5a3a20bb2c..b266a830d1 100644 --- a/lib/core/context-menu/context-menu.spec.ts +++ b/lib/core/context-menu/context-menu.spec.ts @@ -20,6 +20,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { ContextMenuModule } from './context-menu.module'; import { CoreModule } from '../core.module'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; +import { setupTestBed } from '../testing/setupTestBed'; @Component({ selector: 'adf-test-component', @@ -78,18 +79,18 @@ describe('ContextMenuDirective', () => { } ]; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - CoreModule.forRoot(), - ContextMenuModule, - NoopAnimationsModule - ], - declarations: [ - TestComponent - ] - }); + setupTestBed({ + imports: [ + CoreModule.forRoot(), + ContextMenuModule, + NoopAnimationsModule + ], + declarations: [ + TestComponent + ] + }); + beforeEach(() => { fixture = TestBed.createComponent(TestComponent); fixture.componentInstance.actions = actions; fixture.detectChanges(); diff --git a/lib/core/karma.conf.js b/lib/core/karma.conf.js index a46e16d80e..47c44d0143 100644 --- a/lib/core/karma.conf.js +++ b/lib/core/karma.conf.js @@ -18,7 +18,6 @@ module.exports = function (config) { {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/@angular/material/prebuilt-themes/indigo-pink.css', included: true, @@ -56,6 +55,7 @@ module.exports = function (config) { '/base/assets/' :'/base/lib/core/assets/', '/assets/adf-core/i18n/en.json': '/base/lib/core/i18n/en.json', '/assets/adf-core/i18n/en-GB.json': '/base/lib/core/i18n/en.json', + '/assets/adf-core/i18n/en-US.json': '/base/lib/core/i18n/en.json', '/app.config.json': '/base/lib/config/app.config.json', '/fake-test-file.pdf': '/base/lib/core/viewer/assets/fake-test-file.pdf', '/fake-test-file.txt': '/base/lib/core/viewer/assets/fake-test-file.txt', diff --git a/lib/core/layout/components/header/header.component.spec.ts b/lib/core/layout/components/header/header.component.spec.ts index 37f51524cd..3242d853ee 100644 --- a/lib/core/layout/components/header/header.component.spec.ts +++ b/lib/core/layout/components/header/header.component.spec.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HeaderLayoutComponent } from './header.component'; import { setupTestBed } from '../../../testing/setupTestBed'; import { CoreTestingModule } from '../../../testing/core.testing.module'; @@ -151,13 +151,10 @@ describe('HeaderLayoutComponent', () => { }) class HeaderLayoutTesterComponent {} - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [HeaderLayoutTesterComponent], - imports: [ CoreTestingModule, LayoutModule, MaterialModule, RouterTestingModule ] - }) - .compileComponents(); - })); + setupTestBed({ + declarations: [HeaderLayoutTesterComponent], + imports: [ CoreTestingModule, LayoutModule, MaterialModule, RouterTestingModule ] + }); it('should project the provided nodes into the component', () => { const hostFixture = TestBed.createComponent(HeaderLayoutTesterComponent); 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 9417e9e306..4634444800 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 @@ -16,7 +16,7 @@ */ import { Component } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MaterialModule } from '../../../material.module'; import { SidebarActionMenuComponent } from './sidebar-action-menu.component'; import { setupTestBed } from '../../../testing/setupTestBed'; @@ -57,23 +57,23 @@ describe('SidebarActionMenuComponent', () => { @Component({ template: ` - - arrow_drop_down -
- queue -
-
- - -
-
- ` + + arrow_drop_down +
+ queue +
+
+ + +
+
+ ` }) class CustomSidebarActionMenuComponent { title: string = 'Fake title'; @@ -85,17 +85,15 @@ describe('Custom SidebarActionMenuComponent', () => { let component: CustomSidebarActionMenuComponent; let element: HTMLElement; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ - SidebarActionMenuComponent, - CustomSidebarActionMenuComponent - ], - imports: [ - MaterialModule - ] - }).compileComponents(); - })); + setupTestBed({ + declarations: [ + SidebarActionMenuComponent, + CustomSidebarActionMenuComponent + ], + imports: [ + MaterialModule + ] + }); beforeEach(() => { fixture = TestBed.createComponent(CustomSidebarActionMenuComponent); diff --git a/lib/core/services/jwt-helper.service.spec.ts b/lib/core/services/jwt-helper.service.spec.ts index 73858dd806..f5b0d57d71 100644 --- a/lib/core/services/jwt-helper.service.spec.ts +++ b/lib/core/services/jwt-helper.service.spec.ts @@ -15,18 +15,20 @@ * limitations under the License. */ -import { TestBed } from '@angular/core/testing'; import { JwtHelperService } from './jwt-helper.service'; import { mockToken } from './../mock/jwt-helper.service.spec'; +import { setupTestBed } from '../testing/setupTestBed'; +import { TestBed } from '@angular/core/testing'; describe('JwtHelperService', () => { let jwtHelperService: JwtHelperService; + setupTestBed({ + providers: [JwtHelperService] + }); + beforeEach(() => { - TestBed.configureTestingModule({ - providers: [JwtHelperService] - }); jwtHelperService = TestBed.get(JwtHelperService); }); diff --git a/lib/core/services/lock.service.spec.ts b/lib/core/services/lock.service.spec.ts index 53ce615a88..c9328e83b6 100644 --- a/lib/core/services/lock.service.spec.ts +++ b/lib/core/services/lock.service.spec.ts @@ -60,8 +60,10 @@ describe('PeopleProcessService', () => { isLocked: true, isFile: true, properties: - { 'cm:lockType': 'READ_ONLY_LOCK', - 'cm:lockLifetime': 'PERSISTENT' } + { + 'cm:lockType': 'READ_ONLY_LOCK', + 'cm:lockLifetime': 'PERSISTENT' + } }; const nodeReadOnlyWithExpiredDate: Node = { @@ -69,12 +71,12 @@ describe('PeopleProcessService', () => { isLocked: true, isFile: true, properties: - { - 'cm:lockType': 'WRITE_LOCK', - 'cm:lockLifetime': 'PERSISTENT', - 'cm:lockOwner': { id: 'lock-owner-user' }, - 'cm:expiryDate': moment().subtract('days', '4') - } + { + 'cm:lockType': 'WRITE_LOCK', + 'cm:lockLifetime': 'PERSISTENT', + 'cm:lockOwner': { id: 'lock-owner-user' }, + 'cm:expiryDate': moment().subtract(4, 'days') + } }; const nodeReadOnlyWithActiveExpiration: Node = { @@ -82,12 +84,12 @@ describe('PeopleProcessService', () => { isLocked: true, isFile: true, properties: - { - 'cm:lockType': 'WRITE_LOCK', - 'cm:lockLifetime': 'PERSISTENT', - 'cm:lockOwner': { id: 'lock-owner-user' }, - 'cm:expiryDate': moment().add('days', '4') - } + { + 'cm:lockType': 'WRITE_LOCK', + 'cm:lockLifetime': 'PERSISTENT', + 'cm:lockOwner': { id: 'lock-owner-user' }, + 'cm:expiryDate': moment().add(4, 'days') + } }; it('should return true when readonly lock is active', () => { @@ -109,11 +111,11 @@ describe('PeopleProcessService', () => { isLocked: true, isFile: true, properties: - { - 'cm:lockType': 'WRITE_LOCK', - 'cm:lockLifetime': 'PERSISTENT', - 'cm:lockOwner': { id: 'lock-owner-user' } - } + { + 'cm:lockType': 'WRITE_LOCK', + 'cm:lockLifetime': 'PERSISTENT', + 'cm:lockOwner': { id: 'lock-owner-user' } + } }; const nodeOwnerAllowedLockWithExpiredDate: Node = { @@ -121,12 +123,12 @@ describe('PeopleProcessService', () => { isLocked: true, isFile: true, properties: - { - 'cm:lockType': 'WRITE_LOCK', - 'cm:lockLifetime': 'PERSISTENT', - 'cm:lockOwner': { id: 'lock-owner-user' }, - 'cm:expiryDate': moment().subtract('days', '4') - } + { + 'cm:lockType': 'WRITE_LOCK', + 'cm:lockLifetime': 'PERSISTENT', + 'cm:lockOwner': { id: 'lock-owner-user' }, + 'cm:expiryDate': moment().subtract(4, 'days') + } }; const nodeOwnerAllowedLockWithActiveExpiration: Node = { @@ -134,12 +136,12 @@ describe('PeopleProcessService', () => { isLocked: true, isFile: true, properties: - { - 'cm:lockType': 'WRITE_LOCK', - 'cm:lockLifetime': 'PERSISTENT', - 'cm:lockOwner': { id: 'lock-owner-user' }, - 'cm:expiryDate': moment().add('days', '4') - } + { + 'cm:lockType': 'WRITE_LOCK', + 'cm:lockLifetime': 'PERSISTENT', + 'cm:lockOwner': { id: 'lock-owner-user' }, + 'cm:expiryDate': moment().add(4, 'days') + } }; it('should return false when the user is the lock owner', () => { diff --git a/lib/core/services/log.service.spec.ts b/lib/core/services/log.service.spec.ts index d8deda5740..c73dcd4d01 100644 --- a/lib/core/services/log.service.spec.ts +++ b/lib/core/services/log.service.spec.ts @@ -17,9 +17,10 @@ import { HttpClientModule } from '@angular/common/http'; import { Component } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { AppConfigService } from '../app-config/app-config.service'; import { LogService } from './log.service'; +import { setupTestBed } from '../testing/setupTestBed'; @Component({ template: '', @@ -61,20 +62,16 @@ describe('Log Service', () => { let providesLogComponent: ComponentFixture; let appConfigService: AppConfigService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - HttpClientModule - ], - declarations: [ProvidesLogComponent], - providers: [ - LogService, - AppConfigService - ] - }); - - TestBed.compileComponents(); - })); + setupTestBed({ + imports: [ + HttpClientModule + ], + declarations: [ProvidesLogComponent], + providers: [ + LogService, + AppConfigService + ] + }); beforeEach(() => { appConfigService = TestBed.get(AppConfigService); diff --git a/lib/core/services/notification.service.spec.ts b/lib/core/services/notification.service.spec.ts index fba92dbce9..d0e82a4f9e 100644 --- a/lib/core/services/notification.service.spec.ts +++ b/lib/core/services/notification.service.spec.ts @@ -18,7 +18,7 @@ import { LiveAnnouncer } from '@angular/cdk/a11y'; import { OVERLAY_PROVIDERS, OverlayModule } from '@angular/cdk/overlay'; import { Component } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MatSnackBar, MatSnackBarModule, MatSnackBarConfig } from '@angular/material'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; @@ -26,6 +26,7 @@ import { NotificationService } from './notification.service'; import { TranslationMock } from '../mock/translation.service.mock'; import { TranslationService } from './translation.service'; import { HttpClientModule } from '@angular/common/http'; +import { setupTestBed } from '../testing/setupTestBed'; @Component({ template: '', @@ -37,33 +38,33 @@ class ProvidesNotificationServiceComponent { } sendMessageWithoutConfig() { - const promise = this.notificationService.openSnackMessage('Test notification', 1000); - return promise; + return this.notificationService.openSnackMessage('Test notification', 1000); } sendMessage() { - const promise = this.notificationService.openSnackMessage('Test notification', 1000); - return promise; + return this.notificationService.openSnackMessage('Test notification', 1000); } sendCustomMessage() { - const promise = this.notificationService.openSnackMessage('Test notification', new MatSnackBarConfig()); - return promise; + const matSnackBarConfig = new MatSnackBarConfig(); + matSnackBarConfig.duration = 1000; + + return this.notificationService.openSnackMessage('Test notification', matSnackBarConfig); } sendMessageActionWithoutConfig() { - const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000); - return promise; + return this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000); } sendMessageAction() { - const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000); - return promise; + return this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000); } sendCustomMessageAction() { - const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig()); - return promise; + const matSnackBarConfig = new MatSnackBarConfig(); + matSnackBarConfig.duration = 1000; + + return this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', matSnackBarConfig); } } @@ -72,28 +73,25 @@ describe('NotificationService', () => { let fixture: ComponentFixture; let translationService: TranslationService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - NoopAnimationsModule, - OverlayModule, - MatSnackBarModule, - HttpClientModule - ], - declarations: [ProvidesNotificationServiceComponent], - providers: [ - NotificationService, - MatSnackBar, - OVERLAY_PROVIDERS, - LiveAnnouncer, - { provide: TranslationService, useClass: TranslationMock } - ] - }); - - translationService = TestBed.get(TranslationService); - })); + setupTestBed({ + imports: [ + NoopAnimationsModule, + OverlayModule, + MatSnackBarModule, + HttpClientModule + ], + declarations: [ProvidesNotificationServiceComponent], + providers: [ + NotificationService, + MatSnackBar, + OVERLAY_PROVIDERS, + LiveAnnouncer, + { provide: TranslationService, useClass: TranslationMock } + ] + }); beforeEach(() => { + translationService = TestBed.get(TranslationService); fixture = TestBed.createComponent(ProvidesNotificationServiceComponent); fixture.detectChanges(); }); @@ -132,7 +130,7 @@ describe('NotificationService', () => { expect(document.querySelector('snack-bar-container')).not.toBeNull(); }); - it('should open a message notification bar with custom configuration', async((done) => { + it('should open a message notification bar with custom configuration', (done) => { const promise = fixture.componentInstance.sendCustomMessage(); promise.afterDismissed().subscribe(() => { done(); @@ -141,7 +139,7 @@ describe('NotificationService', () => { fixture.detectChanges(); expect(document.querySelector('snack-bar-container')).not.toBeNull(); - })); + }); it('should open a message notification bar with action', (done) => { const promise = fixture.componentInstance.sendMessageAction(); @@ -154,7 +152,7 @@ describe('NotificationService', () => { expect(document.querySelector('snack-bar-container')).not.toBeNull(); }); - it('should open a message notification bar with action and custom configuration', async((done) => { + it('should open a message notification bar with action and custom configuration', (done) => { const promise = fixture.componentInstance.sendCustomMessageAction(); promise.afterDismissed().subscribe(() => { done(); @@ -163,7 +161,7 @@ describe('NotificationService', () => { fixture.detectChanges(); expect(document.querySelector('snack-bar-container')).not.toBeNull(); - })); + }); it('should open a message notification bar with action and no custom configuration', (done) => { const promise = fixture.componentInstance.sendMessageActionWithoutConfig(); diff --git a/lib/insights/diagram/components/tooltip/diagram-tooltip.component.spec.ts b/lib/insights/diagram/components/tooltip/diagram-tooltip.component.spec.ts index 7a18134ff4..00e779d07f 100644 --- a/lib/insights/diagram/components/tooltip/diagram-tooltip.component.spec.ts +++ b/lib/insights/diagram/components/tooltip/diagram-tooltip.component.spec.ts @@ -16,9 +16,10 @@ */ import { Component } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { DiagramTooltipComponent } from './diagram-tooltip.component'; +import { setupTestBed } from '../../../../core/testing/setupTestBed'; @Component({ template: ` @@ -39,11 +40,9 @@ describe('DiagramTooltipComponent', () => { let component: DiagramTooltipComponent; let data; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [DiagramTooltipComponent] - }).compileComponents(); - })); + setupTestBed({ + declarations: [DiagramTooltipComponent] + }); beforeEach(() => { fixture = TestBed.createComponent(DiagramTooltipComponent); @@ -127,11 +126,9 @@ describe('DiagramTooltipComponent', () => { let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [DiagramTooltipComponent, TestHostComponent] - }).compileComponents(); - })); + setupTestBed({ + declarations: [DiagramTooltipComponent, TestHostComponent] + }); beforeEach(() => { fixture = TestBed.createComponent(TestHostComponent); diff --git a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts index eb89b3832b..86ba05eb78 100644 --- a/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts +++ b/lib/process-services-cloud/src/lib/app/components/app-list-cloud.component.spec.ts @@ -40,21 +40,13 @@ describe('AppListCloudComponent', () => { } }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule], - providers: [ - AppsProcessCloudService - ] - }) - .overrideComponent(AppListCloudComponent, { - set: { - providers: [ - { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock } - ] - } - }).compileComponents(); - })); + setupTestBed({ + imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule], + providers: [ + AppsProcessCloudService, + { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock } + ] + }); beforeEach(() => { fixture = TestBed.createComponent(AppListCloudComponent);