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.
|
* 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 { NameLocationCellComponent } from './name-location-cell.component';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { DataRow } from '@alfresco/adf-core';
|
import { DataRow } from '@alfresco/adf-core';
|
||||||
|
import { setupTestBed } from '../../../core/testing/setupTestBed';
|
||||||
|
|
||||||
describe('NameLocationCellComponent', () => {
|
describe('NameLocationCellComponent', () => {
|
||||||
let component: NameLocationCellComponent;
|
let component: NameLocationCellComponent;
|
||||||
let fixture: ComponentFixture<NameLocationCellComponent>;
|
let fixture: ComponentFixture<NameLocationCellComponent>;
|
||||||
let rowData: DataRow;
|
let rowData: DataRow;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
declarations: [
|
||||||
declarations: [
|
NameLocationCellComponent
|
||||||
NameLocationCellComponent
|
]
|
||||||
]
|
});
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(NameLocationCellComponent);
|
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 { FileModel, CoreModule, FileUploadOptions, FileUploadStatus } from '@alfresco/adf-core';
|
||||||
import { UploadModule } from '../upload.module';
|
import { UploadModule } from '../upload.module';
|
||||||
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
||||||
|
import { setupTestBed } from '../../../core/testing/setupTestBed';
|
||||||
|
|
||||||
describe('FileUploadingListRowComponent', () => {
|
describe('FileUploadingListRowComponent', () => {
|
||||||
let fixture: ComponentFixture<FileUploadingListRowComponent>;
|
let fixture: ComponentFixture<FileUploadingListRowComponent>;
|
||||||
let component: FileUploadingListRowComponent;
|
let component: FileUploadingListRowComponent;
|
||||||
const file = new FileModel(<File> { name: 'fake-name' });
|
const file = new FileModel(<File> { name: 'fake-name' });
|
||||||
|
|
||||||
beforeEach(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [
|
||||||
imports: [
|
CoreModule.forRoot(),
|
||||||
CoreModule.forRoot(),
|
UploadModule
|
||||||
UploadModule
|
]
|
||||||
]
|
|
||||||
}).compileComponents();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
import { async, TestBed } from '@angular/core/testing';
|
import { async, TestBed } from '@angular/core/testing';
|
||||||
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
import { CardViewBaseItemModel } from '../models/card-view-baseitem.model';
|
||||||
import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service';
|
import { CardViewUpdateService, transformKeyToObject } from './card-view-update.service';
|
||||||
|
import { setupTestBed } from '../../testing/setupTestBed';
|
||||||
|
|
||||||
describe('CardViewUpdateService', () => {
|
describe('CardViewUpdateService', () => {
|
||||||
|
|
||||||
@@ -58,13 +59,11 @@ describe('CardViewUpdateService', () => {
|
|||||||
clickable: false
|
clickable: false
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
providers: [
|
||||||
providers: [
|
CardViewUpdateService
|
||||||
CardViewUpdateService
|
]
|
||||||
]
|
});
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
cardViewUpdateService = TestBed.get(CardViewUpdateService);
|
||||||
|
@@ -26,26 +26,25 @@ import { AppConfigServiceMock } from '../mock/app-config.service.mock';
|
|||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { MatSnackBarModule } from '@angular/material';
|
import { MatSnackBarModule } from '@angular/material';
|
||||||
import { TranslationMock } from '@alfresco/adf-core';
|
import { TranslationMock } from '@alfresco/adf-core';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
|
||||||
describe('ClipboardService', () => {
|
describe('ClipboardService', () => {
|
||||||
let clipboardService: ClipboardService;
|
let clipboardService: ClipboardService;
|
||||||
let notificationService: NotificationService;
|
let notificationService: NotificationService;
|
||||||
let inputElement;
|
let inputElement;
|
||||||
|
|
||||||
beforeEach(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [
|
||||||
imports: [
|
ClipboardModule,
|
||||||
ClipboardModule,
|
HttpClientModule,
|
||||||
HttpClientModule,
|
MatSnackBarModule
|
||||||
MatSnackBarModule
|
],
|
||||||
],
|
providers: [
|
||||||
providers: [
|
LogService,
|
||||||
LogService,
|
{ provide: TranslationService, useClass: TranslationMock },
|
||||||
{ provide: TranslationService, useClass: TranslationMock },
|
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
||||||
{ provide: AppConfigService, useClass: AppConfigServiceMock },
|
NotificationService
|
||||||
NotificationService
|
]
|
||||||
]
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
@@ -117,10 +117,10 @@ describe('CommentListComponent', () => {
|
|||||||
|
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
ecmUserService = TestBed.get(EcmUserService);
|
ecmUserService = TestBed.get(EcmUserService);
|
||||||
spyOn(ecmUserService, 'getUserProfileImage').and.returnValue('content-user-image');
|
spyOn(ecmUserService, 'getUserProfileImage').and.returnValue('alfresco-logo.svg');
|
||||||
|
|
||||||
peopleProcessService = TestBed.get(PeopleProcessService);
|
peopleProcessService = TestBed.get(PeopleProcessService);
|
||||||
spyOn(peopleProcessService, 'getUserImage').and.returnValue('process-user-image');
|
spyOn(peopleProcessService, 'getUserImage').and.returnValue('alfresco-logo.svg');
|
||||||
|
|
||||||
fixture = TestBed.createComponent(CommentListComponent);
|
fixture = TestBed.createComponent(CommentListComponent);
|
||||||
commentList = fixture.componentInstance;
|
commentList = fixture.componentInstance;
|
||||||
@@ -259,7 +259,7 @@ describe('CommentListComponent', () => {
|
|||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
const elements = fixture.nativeElement.querySelectorAll('.adf-people-img');
|
const elements = fixture.nativeElement.querySelectorAll('.adf-people-img');
|
||||||
expect(elements.length).toBe(1);
|
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(() => {
|
fixture.whenStable().then(() => {
|
||||||
const elements = fixture.nativeElement.querySelectorAll('.adf-people-img');
|
const elements = fixture.nativeElement.querySelectorAll('.adf-people-img');
|
||||||
expect(elements.length).toBe(1);
|
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 { ContextMenuService } from './context-menu.service';
|
||||||
import { CoreModule } from '../core.module';
|
import { CoreModule } from '../core.module';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
|
||||||
describe('ContextMenuHolderComponent', () => {
|
describe('ContextMenuHolderComponent', () => {
|
||||||
let fixture: ComponentFixture<ContextMenuHolderComponent>;
|
let fixture: ComponentFixture<ContextMenuHolderComponent>;
|
||||||
@@ -52,25 +53,25 @@ describe('ContextMenuHolderComponent', () => {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [
|
||||||
imports: [
|
NoopAnimationsModule,
|
||||||
NoopAnimationsModule,
|
CoreModule.forRoot(),
|
||||||
CoreModule.forRoot(),
|
ContextMenuModule
|
||||||
ContextMenuModule
|
],
|
||||||
],
|
providers: [
|
||||||
providers: [
|
{
|
||||||
{
|
provide: OverlayContainer,
|
||||||
provide: OverlayContainer,
|
useValue: overlayContainer
|
||||||
useValue: overlayContainer
|
},
|
||||||
},
|
{
|
||||||
{
|
provide: ViewportRuler,
|
||||||
provide: ViewportRuler,
|
useValue: getViewportRect
|
||||||
useValue: getViewportRect
|
}
|
||||||
}
|
]
|
||||||
]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ContextMenuHolderComponent);
|
fixture = TestBed.createComponent(ContextMenuHolderComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
contextMenuService = TestBed.get(ContextMenuService);
|
contextMenuService = TestBed.get(ContextMenuService);
|
||||||
|
@@ -15,12 +15,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
import { Overlay } from '@angular/cdk/overlay';
|
import { Overlay } from '@angular/cdk/overlay';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||||
import { ContextMenuOverlayService } from './context-menu-overlay.service';
|
import { ContextMenuOverlayService } from './context-menu-overlay.service';
|
||||||
import { Injector } from '@angular/core';
|
import { Injector } from '@angular/core';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
describe('ContextMenuService', () => {
|
describe('ContextMenuService', () => {
|
||||||
let contextMenuOverlayService: ContextMenuOverlayService;
|
let contextMenuOverlayService: ContextMenuOverlayService;
|
||||||
@@ -34,12 +35,12 @@ describe('ContextMenuService', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [NoopAnimationsModule, CoreTestingModule],
|
||||||
imports: [NoopAnimationsModule, CoreTestingModule],
|
providers: [ Overlay ]
|
||||||
providers: [ Overlay ]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
overlay = TestBed.get(Overlay);
|
overlay = TestBed.get(Overlay);
|
||||||
injector = TestBed.get(Injector);
|
injector = TestBed.get(Injector);
|
||||||
});
|
});
|
||||||
|
@@ -20,6 +20,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing';
|
|||||||
import { ContextMenuModule } from './context-menu.module';
|
import { ContextMenuModule } from './context-menu.module';
|
||||||
import { CoreModule } from '../core.module';
|
import { CoreModule } from '../core.module';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'adf-test-component',
|
selector: 'adf-test-component',
|
||||||
@@ -78,18 +79,18 @@ describe('ContextMenuDirective', () => {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
beforeEach(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [
|
||||||
imports: [
|
CoreModule.forRoot(),
|
||||||
CoreModule.forRoot(),
|
ContextMenuModule,
|
||||||
ContextMenuModule,
|
NoopAnimationsModule
|
||||||
NoopAnimationsModule
|
],
|
||||||
],
|
declarations: [
|
||||||
declarations: [
|
TestComponent
|
||||||
TestComponent
|
]
|
||||||
]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(TestComponent);
|
fixture = TestBed.createComponent(TestComponent);
|
||||||
fixture.componentInstance.actions = actions;
|
fixture.componentInstance.actions = actions;
|
||||||
fixture.detectChanges();
|
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.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/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', included: true, watched: false},
|
||||||
|
|
||||||
{
|
{
|
||||||
pattern: 'node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
|
pattern: 'node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
|
||||||
included: true,
|
included: true,
|
||||||
@@ -56,6 +55,7 @@ module.exports = function (config) {
|
|||||||
'/base/assets/' :'/base/lib/core/assets/',
|
'/base/assets/' :'/base/lib/core/assets/',
|
||||||
'/assets/adf-core/i18n/en.json': '/base/lib/core/i18n/en.json',
|
'/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-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',
|
'/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.pdf': '/base/lib/core/viewer/assets/fake-test-file.pdf',
|
||||||
'/fake-test-file.txt': '/base/lib/core/viewer/assets/fake-test-file.txt',
|
'/fake-test-file.txt': '/base/lib/core/viewer/assets/fake-test-file.txt',
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* 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 { HeaderLayoutComponent } from './header.component';
|
||||||
import { setupTestBed } from '../../../testing/setupTestBed';
|
import { setupTestBed } from '../../../testing/setupTestBed';
|
||||||
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
import { CoreTestingModule } from '../../../testing/core.testing.module';
|
||||||
@@ -151,13 +151,10 @@ describe('HeaderLayoutComponent', () => {
|
|||||||
})
|
})
|
||||||
class HeaderLayoutTesterComponent {}
|
class HeaderLayoutTesterComponent {}
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
declarations: [HeaderLayoutTesterComponent],
|
||||||
declarations: [HeaderLayoutTesterComponent],
|
imports: [ CoreTestingModule, LayoutModule, MaterialModule, RouterTestingModule ]
|
||||||
imports: [ CoreTestingModule, LayoutModule, MaterialModule, RouterTestingModule ]
|
});
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should project the provided nodes into the component', () => {
|
it('should project the provided nodes into the component', () => {
|
||||||
const hostFixture = TestBed.createComponent(HeaderLayoutTesterComponent);
|
const hostFixture = TestBed.createComponent(HeaderLayoutTesterComponent);
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
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 { MaterialModule } from '../../../material.module';
|
||||||
import { SidebarActionMenuComponent } from './sidebar-action-menu.component';
|
import { SidebarActionMenuComponent } from './sidebar-action-menu.component';
|
||||||
import { setupTestBed } from '../../../testing/setupTestBed';
|
import { setupTestBed } from '../../../testing/setupTestBed';
|
||||||
@@ -57,23 +57,23 @@ describe('SidebarActionMenuComponent', () => {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
<adf-sidebar-action-menu [expanded]="expanded" [title]="title">
|
<adf-sidebar-action-menu [expanded]="expanded" [title]="title">
|
||||||
<mat-icon adf-sidebar-menu-title-icon>arrow_drop_down</mat-icon>
|
<mat-icon adf-sidebar-menu-title-icon>arrow_drop_down</mat-icon>
|
||||||
<div adf-sidebar-menu-expand-icon>
|
<div adf-sidebar-menu-expand-icon>
|
||||||
<mat-icon>queue</mat-icon>
|
<mat-icon>queue</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div adf-sidebar-menu-options>
|
<div adf-sidebar-menu-options>
|
||||||
<button mat-menu-item>
|
<button mat-menu-item>
|
||||||
<mat-icon>assignment</mat-icon>
|
<mat-icon>assignment</mat-icon>
|
||||||
<span>Option1</span>
|
<span>Option1</span>
|
||||||
</button>
|
</button>
|
||||||
<button mat-menu-item>
|
<button mat-menu-item>
|
||||||
<mat-icon>assignment</mat-icon>
|
<mat-icon>assignment</mat-icon>
|
||||||
<span>Option2</span>
|
<span>Option2</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</adf-sidebar-action-menu>
|
</adf-sidebar-action-menu>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
class CustomSidebarActionMenuComponent {
|
class CustomSidebarActionMenuComponent {
|
||||||
title: string = 'Fake title';
|
title: string = 'Fake title';
|
||||||
@@ -85,17 +85,15 @@ describe('Custom SidebarActionMenuComponent', () => {
|
|||||||
let component: CustomSidebarActionMenuComponent;
|
let component: CustomSidebarActionMenuComponent;
|
||||||
let element: HTMLElement;
|
let element: HTMLElement;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
declarations: [
|
||||||
declarations: [
|
SidebarActionMenuComponent,
|
||||||
SidebarActionMenuComponent,
|
CustomSidebarActionMenuComponent
|
||||||
CustomSidebarActionMenuComponent
|
],
|
||||||
],
|
imports: [
|
||||||
imports: [
|
MaterialModule
|
||||||
MaterialModule
|
]
|
||||||
]
|
});
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(CustomSidebarActionMenuComponent);
|
fixture = TestBed.createComponent(CustomSidebarActionMenuComponent);
|
||||||
|
@@ -15,18 +15,20 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { TestBed } from '@angular/core/testing';
|
|
||||||
import { JwtHelperService } from './jwt-helper.service';
|
import { JwtHelperService } from './jwt-helper.service';
|
||||||
import { mockToken } from './../mock/jwt-helper.service.spec';
|
import { mockToken } from './../mock/jwt-helper.service.spec';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
describe('JwtHelperService', () => {
|
describe('JwtHelperService', () => {
|
||||||
|
|
||||||
let jwtHelperService: JwtHelperService;
|
let jwtHelperService: JwtHelperService;
|
||||||
|
|
||||||
|
setupTestBed({
|
||||||
|
providers: [JwtHelperService]
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
|
||||||
providers: [JwtHelperService]
|
|
||||||
});
|
|
||||||
jwtHelperService = TestBed.get(JwtHelperService);
|
jwtHelperService = TestBed.get(JwtHelperService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -60,8 +60,10 @@ describe('PeopleProcessService', () => {
|
|||||||
isLocked: true,
|
isLocked: true,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
properties:
|
properties:
|
||||||
{ 'cm:lockType': 'READ_ONLY_LOCK',
|
{
|
||||||
'cm:lockLifetime': 'PERSISTENT' }
|
'cm:lockType': 'READ_ONLY_LOCK',
|
||||||
|
'cm:lockLifetime': 'PERSISTENT'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeReadOnlyWithExpiredDate: Node = <Node> {
|
const nodeReadOnlyWithExpiredDate: Node = <Node> {
|
||||||
@@ -69,12 +71,12 @@ describe('PeopleProcessService', () => {
|
|||||||
isLocked: true,
|
isLocked: true,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
properties:
|
properties:
|
||||||
{
|
{
|
||||||
'cm:lockType': 'WRITE_LOCK',
|
'cm:lockType': 'WRITE_LOCK',
|
||||||
'cm:lockLifetime': 'PERSISTENT',
|
'cm:lockLifetime': 'PERSISTENT',
|
||||||
'cm:lockOwner': { id: 'lock-owner-user' },
|
'cm:lockOwner': { id: 'lock-owner-user' },
|
||||||
'cm:expiryDate': moment().subtract('days', '4')
|
'cm:expiryDate': moment().subtract(4, 'days')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeReadOnlyWithActiveExpiration: Node = <Node> {
|
const nodeReadOnlyWithActiveExpiration: Node = <Node> {
|
||||||
@@ -82,12 +84,12 @@ describe('PeopleProcessService', () => {
|
|||||||
isLocked: true,
|
isLocked: true,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
properties:
|
properties:
|
||||||
{
|
{
|
||||||
'cm:lockType': 'WRITE_LOCK',
|
'cm:lockType': 'WRITE_LOCK',
|
||||||
'cm:lockLifetime': 'PERSISTENT',
|
'cm:lockLifetime': 'PERSISTENT',
|
||||||
'cm:lockOwner': { id: 'lock-owner-user' },
|
'cm:lockOwner': { id: 'lock-owner-user' },
|
||||||
'cm:expiryDate': moment().add('days', '4')
|
'cm:expiryDate': moment().add(4, 'days')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should return true when readonly lock is active', () => {
|
it('should return true when readonly lock is active', () => {
|
||||||
@@ -109,11 +111,11 @@ describe('PeopleProcessService', () => {
|
|||||||
isLocked: true,
|
isLocked: true,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
properties:
|
properties:
|
||||||
{
|
{
|
||||||
'cm:lockType': 'WRITE_LOCK',
|
'cm:lockType': 'WRITE_LOCK',
|
||||||
'cm:lockLifetime': 'PERSISTENT',
|
'cm:lockLifetime': 'PERSISTENT',
|
||||||
'cm:lockOwner': { id: 'lock-owner-user' }
|
'cm:lockOwner': { id: 'lock-owner-user' }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeOwnerAllowedLockWithExpiredDate: Node = <Node> {
|
const nodeOwnerAllowedLockWithExpiredDate: Node = <Node> {
|
||||||
@@ -121,12 +123,12 @@ describe('PeopleProcessService', () => {
|
|||||||
isLocked: true,
|
isLocked: true,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
properties:
|
properties:
|
||||||
{
|
{
|
||||||
'cm:lockType': 'WRITE_LOCK',
|
'cm:lockType': 'WRITE_LOCK',
|
||||||
'cm:lockLifetime': 'PERSISTENT',
|
'cm:lockLifetime': 'PERSISTENT',
|
||||||
'cm:lockOwner': { id: 'lock-owner-user' },
|
'cm:lockOwner': { id: 'lock-owner-user' },
|
||||||
'cm:expiryDate': moment().subtract('days', '4')
|
'cm:expiryDate': moment().subtract(4, 'days')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const nodeOwnerAllowedLockWithActiveExpiration: Node = <Node> {
|
const nodeOwnerAllowedLockWithActiveExpiration: Node = <Node> {
|
||||||
@@ -134,12 +136,12 @@ describe('PeopleProcessService', () => {
|
|||||||
isLocked: true,
|
isLocked: true,
|
||||||
isFile: true,
|
isFile: true,
|
||||||
properties:
|
properties:
|
||||||
{
|
{
|
||||||
'cm:lockType': 'WRITE_LOCK',
|
'cm:lockType': 'WRITE_LOCK',
|
||||||
'cm:lockLifetime': 'PERSISTENT',
|
'cm:lockLifetime': 'PERSISTENT',
|
||||||
'cm:lockOwner': { id: 'lock-owner-user' },
|
'cm:lockOwner': { id: 'lock-owner-user' },
|
||||||
'cm:expiryDate': moment().add('days', '4')
|
'cm:expiryDate': moment().add(4, 'days')
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should return false when the user is the lock owner', () => {
|
it('should return false when the user is the lock owner', () => {
|
||||||
|
@@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { Component } from '@angular/core';
|
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 { AppConfigService } from '../app-config/app-config.service';
|
||||||
import { LogService } from './log.service';
|
import { LogService } from './log.service';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
@@ -61,20 +62,16 @@ describe('Log Service', () => {
|
|||||||
let providesLogComponent: ComponentFixture<ProvidesLogComponent>;
|
let providesLogComponent: ComponentFixture<ProvidesLogComponent>;
|
||||||
let appConfigService: AppConfigService;
|
let appConfigService: AppConfigService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [
|
||||||
imports: [
|
HttpClientModule
|
||||||
HttpClientModule
|
],
|
||||||
],
|
declarations: [ProvidesLogComponent],
|
||||||
declarations: [ProvidesLogComponent],
|
providers: [
|
||||||
providers: [
|
LogService,
|
||||||
LogService,
|
AppConfigService
|
||||||
AppConfigService
|
]
|
||||||
]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
TestBed.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
appConfigService = TestBed.get(AppConfigService);
|
appConfigService = TestBed.get(AppConfigService);
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { LiveAnnouncer } from '@angular/cdk/a11y';
|
import { LiveAnnouncer } from '@angular/cdk/a11y';
|
||||||
import { OVERLAY_PROVIDERS, OverlayModule } from '@angular/cdk/overlay';
|
import { OVERLAY_PROVIDERS, OverlayModule } from '@angular/cdk/overlay';
|
||||||
import { Component } from '@angular/core';
|
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 { MatSnackBar, MatSnackBarModule, MatSnackBarConfig } from '@angular/material';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
@@ -26,6 +26,7 @@ import { NotificationService } from './notification.service';
|
|||||||
import { TranslationMock } from '../mock/translation.service.mock';
|
import { TranslationMock } from '../mock/translation.service.mock';
|
||||||
import { TranslationService } from './translation.service';
|
import { TranslationService } from './translation.service';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
|
import { setupTestBed } from '../testing/setupTestBed';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: '',
|
template: '',
|
||||||
@@ -37,33 +38,33 @@ class ProvidesNotificationServiceComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendMessageWithoutConfig() {
|
sendMessageWithoutConfig() {
|
||||||
const promise = this.notificationService.openSnackMessage('Test notification', 1000);
|
return this.notificationService.openSnackMessage('Test notification', 1000);
|
||||||
return promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage() {
|
sendMessage() {
|
||||||
const promise = this.notificationService.openSnackMessage('Test notification', 1000);
|
return this.notificationService.openSnackMessage('Test notification', 1000);
|
||||||
return promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendCustomMessage() {
|
sendCustomMessage() {
|
||||||
const promise = this.notificationService.openSnackMessage('Test notification', new MatSnackBarConfig());
|
const matSnackBarConfig = new MatSnackBarConfig();
|
||||||
return promise;
|
matSnackBarConfig.duration = 1000;
|
||||||
|
|
||||||
|
return this.notificationService.openSnackMessage('Test notification', matSnackBarConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessageActionWithoutConfig() {
|
sendMessageActionWithoutConfig() {
|
||||||
const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
|
return this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
|
||||||
return promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessageAction() {
|
sendMessageAction() {
|
||||||
const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
|
return this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', 1000);
|
||||||
return promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendCustomMessageAction() {
|
sendCustomMessageAction() {
|
||||||
const promise = this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', new MatSnackBarConfig());
|
const matSnackBarConfig = new MatSnackBarConfig();
|
||||||
return promise;
|
matSnackBarConfig.duration = 1000;
|
||||||
|
|
||||||
|
return this.notificationService.openSnackMessageAction('Test notification', 'TestWarn', matSnackBarConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -72,28 +73,25 @@ describe('NotificationService', () => {
|
|||||||
let fixture: ComponentFixture<ProvidesNotificationServiceComponent>;
|
let fixture: ComponentFixture<ProvidesNotificationServiceComponent>;
|
||||||
let translationService: TranslationService;
|
let translationService: TranslationService;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [
|
||||||
imports: [
|
NoopAnimationsModule,
|
||||||
NoopAnimationsModule,
|
OverlayModule,
|
||||||
OverlayModule,
|
MatSnackBarModule,
|
||||||
MatSnackBarModule,
|
HttpClientModule
|
||||||
HttpClientModule
|
],
|
||||||
],
|
declarations: [ProvidesNotificationServiceComponent],
|
||||||
declarations: [ProvidesNotificationServiceComponent],
|
providers: [
|
||||||
providers: [
|
NotificationService,
|
||||||
NotificationService,
|
MatSnackBar,
|
||||||
MatSnackBar,
|
OVERLAY_PROVIDERS,
|
||||||
OVERLAY_PROVIDERS,
|
LiveAnnouncer,
|
||||||
LiveAnnouncer,
|
{ provide: TranslationService, useClass: TranslationMock }
|
||||||
{ provide: TranslationService, useClass: TranslationMock }
|
]
|
||||||
]
|
});
|
||||||
});
|
|
||||||
|
|
||||||
translationService = TestBed.get(TranslationService);
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
translationService = TestBed.get(TranslationService);
|
||||||
fixture = TestBed.createComponent(ProvidesNotificationServiceComponent);
|
fixture = TestBed.createComponent(ProvidesNotificationServiceComponent);
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
@@ -132,7 +130,7 @@ describe('NotificationService', () => {
|
|||||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
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();
|
const promise = fixture.componentInstance.sendCustomMessage();
|
||||||
promise.afterDismissed().subscribe(() => {
|
promise.afterDismissed().subscribe(() => {
|
||||||
done();
|
done();
|
||||||
@@ -141,7 +139,7 @@ describe('NotificationService', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should open a message notification bar with action', (done) => {
|
it('should open a message notification bar with action', (done) => {
|
||||||
const promise = fixture.componentInstance.sendMessageAction();
|
const promise = fixture.componentInstance.sendMessageAction();
|
||||||
@@ -154,7 +152,7 @@ describe('NotificationService', () => {
|
|||||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
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();
|
const promise = fixture.componentInstance.sendCustomMessageAction();
|
||||||
promise.afterDismissed().subscribe(() => {
|
promise.afterDismissed().subscribe(() => {
|
||||||
done();
|
done();
|
||||||
@@ -163,7 +161,7 @@ describe('NotificationService', () => {
|
|||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
expect(document.querySelector('snack-bar-container')).not.toBeNull();
|
||||||
}));
|
});
|
||||||
|
|
||||||
it('should open a message notification bar with action and no custom configuration', (done) => {
|
it('should open a message notification bar with action and no custom configuration', (done) => {
|
||||||
const promise = fixture.componentInstance.sendMessageActionWithoutConfig();
|
const promise = fixture.componentInstance.sendMessageActionWithoutConfig();
|
||||||
|
@@ -16,9 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component } from '@angular/core';
|
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 { By } from '@angular/platform-browser';
|
||||||
import { DiagramTooltipComponent } from './diagram-tooltip.component';
|
import { DiagramTooltipComponent } from './diagram-tooltip.component';
|
||||||
|
import { setupTestBed } from '../../../../core/testing/setupTestBed';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
@@ -39,11 +40,9 @@ describe('DiagramTooltipComponent', () => {
|
|||||||
let component: DiagramTooltipComponent;
|
let component: DiagramTooltipComponent;
|
||||||
let data;
|
let data;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
declarations: [DiagramTooltipComponent]
|
||||||
declarations: [DiagramTooltipComponent]
|
});
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(DiagramTooltipComponent);
|
fixture = TestBed.createComponent(DiagramTooltipComponent);
|
||||||
@@ -127,11 +126,9 @@ describe('DiagramTooltipComponent', () => {
|
|||||||
|
|
||||||
let fixture: ComponentFixture<TestHostComponent>;
|
let fixture: ComponentFixture<TestHostComponent>;
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
declarations: [DiagramTooltipComponent, TestHostComponent]
|
||||||
declarations: [DiagramTooltipComponent, TestHostComponent]
|
});
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(TestHostComponent);
|
fixture = TestBed.createComponent(TestHostComponent);
|
||||||
|
@@ -40,21 +40,13 @@ describe('AppListCloudComponent', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async(() => {
|
setupTestBed({
|
||||||
TestBed.configureTestingModule({
|
imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule],
|
||||||
imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule],
|
providers: [
|
||||||
providers: [
|
AppsProcessCloudService,
|
||||||
AppsProcessCloudService
|
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
|
||||||
]
|
]
|
||||||
})
|
});
|
||||||
.overrideComponent(AppListCloudComponent, {
|
|
||||||
set: {
|
|
||||||
providers: [
|
|
||||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}).compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(AppListCloudComponent);
|
fixture = TestBed.createComponent(AppListCloudComponent);
|
||||||
|
Reference in New Issue
Block a user