mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
clean unit test (#4890)
* promote use setupTestbed * fix comment using right spy and remove deprecated moment method usage * restore md icon file * remove error translation log * restore extension test
This commit is contained in:
@@ -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<NameLocationCellComponent>;
|
||||
let rowData: DataRow;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
NameLocationCellComponent
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
setupTestBed({
|
||||
declarations: [
|
||||
NameLocationCellComponent
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(NameLocationCellComponent);
|
||||
|
@@ -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<FileUploadingListRowComponent>;
|
||||
let component: FileUploadingListRowComponent;
|
||||
const file = new FileModel(<File> { name: 'fake-name' });
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule.forRoot(),
|
||||
UploadModule
|
||||
]
|
||||
}).compileComponents();
|
||||
setupTestBed({
|
||||
imports: [
|
||||
CoreModule.forRoot(),
|
||||
UploadModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -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);
|
||||
|
@@ -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(() => {
|
||||
|
@@ -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');
|
||||
});
|
||||
}));
|
||||
|
||||
|
@@ -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<ContextMenuHolderComponent>;
|
||||
@@ -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);
|
||||
|
@@ -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);
|
||||
});
|
||||
|
@@ -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();
|
||||
|
@@ -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',
|
||||
|
@@ -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);
|
||||
|
@@ -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: `
|
||||
<adf-sidebar-action-menu [expanded]="expanded" [title]="title">
|
||||
<mat-icon adf-sidebar-menu-title-icon>arrow_drop_down</mat-icon>
|
||||
<div adf-sidebar-menu-expand-icon>
|
||||
<mat-icon>queue</mat-icon>
|
||||
</div>
|
||||
<div adf-sidebar-menu-options>
|
||||
<button mat-menu-item>
|
||||
<mat-icon>assignment</mat-icon>
|
||||
<span>Option1</span>
|
||||
</button>
|
||||
<button mat-menu-item>
|
||||
<mat-icon>assignment</mat-icon>
|
||||
<span>Option2</span>
|
||||
</button>
|
||||
</div>
|
||||
</adf-sidebar-action-menu>
|
||||
`
|
||||
<adf-sidebar-action-menu [expanded]="expanded" [title]="title">
|
||||
<mat-icon adf-sidebar-menu-title-icon>arrow_drop_down</mat-icon>
|
||||
<div adf-sidebar-menu-expand-icon>
|
||||
<mat-icon>queue</mat-icon>
|
||||
</div>
|
||||
<div adf-sidebar-menu-options>
|
||||
<button mat-menu-item>
|
||||
<mat-icon>assignment</mat-icon>
|
||||
<span>Option1</span>
|
||||
</button>
|
||||
<button mat-menu-item>
|
||||
<mat-icon>assignment</mat-icon>
|
||||
<span>Option2</span>
|
||||
</button>
|
||||
</div>
|
||||
</adf-sidebar-action-menu>
|
||||
`
|
||||
})
|
||||
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);
|
||||
|
@@ -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);
|
||||
});
|
||||
|
||||
|
@@ -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 = <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 = <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 = <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 = <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', () => {
|
||||
|
@@ -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<ProvidesLogComponent>;
|
||||
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);
|
||||
|
@@ -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<ProvidesNotificationServiceComponent>;
|
||||
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();
|
||||
|
@@ -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<TestHostComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DiagramTooltipComponent, TestHostComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
setupTestBed({
|
||||
declarations: [DiagramTooltipComponent, TestHostComponent]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(TestHostComponent);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user