mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-09-17 14:21:14 +00:00
cleanup unit tests
This commit is contained in:
committed by
Yasa-Nataliya
parent
88305cec95
commit
93f4fac38d
@@ -24,14 +24,16 @@ import { of } from 'rxjs';
|
|||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { CoreModule } from '@alfresco/adf-core';
|
import { CoreModule } from '@alfresco/adf-core';
|
||||||
import { AppHeaderActionsModule } from './header-actions.module';
|
import { AppHeaderActionsModule } from './header-actions.module';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
describe('HeaderActionsComponent', () => {
|
describe('HeaderActionsComponent', () => {
|
||||||
let component: HeaderActionsComponent;
|
|
||||||
let fixture: ComponentFixture<HeaderActionsComponent>;
|
let fixture: ComponentFixture<HeaderActionsComponent>;
|
||||||
|
let router: Router;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AppTestingModule, CoreModule.forRoot(), AppHeaderActionsModule],
|
imports: [AppTestingModule, CoreModule.forRoot(), AppHeaderActionsModule, RouterTestingModule],
|
||||||
declarations: [HeaderActionsComponent]
|
declarations: [HeaderActionsComponent]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,8 +63,9 @@ describe('HeaderActionsComponent', () => {
|
|||||||
])
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router = TestBed.inject(Router);
|
||||||
|
|
||||||
fixture = TestBed.createComponent(HeaderActionsComponent);
|
fixture = TestBed.createComponent(HeaderActionsComponent);
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +73,7 @@ describe('HeaderActionsComponent', () => {
|
|||||||
const getUploadButton = (): HTMLButtonElement => fixture.debugElement.query(By.css('[data-automation-id="upload-button"]')).nativeElement;
|
const getUploadButton = (): HTMLButtonElement => fixture.debugElement.query(By.css('[data-automation-id="upload-button"]')).nativeElement;
|
||||||
|
|
||||||
it('total number of buttons in header should be 2 if route is personal-files', async () => {
|
it('total number of buttons in header should be 2 if route is personal-files', async () => {
|
||||||
spyOn(component, 'isPersonalFilesRoute').and.returnValue(true);
|
spyOnProperty(router, 'url').and.returnValue('/personal-files');
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -83,7 +86,7 @@ describe('HeaderActionsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('total number of buttons in header should be 1 if route is libraries', async () => {
|
it('total number of buttons in header should be 1 if route is libraries', async () => {
|
||||||
spyOn(component, 'isLibrariesRoute').and.returnValue(true);
|
spyOnProperty(router, 'url').and.returnValue('/libraries');
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -95,7 +98,7 @@ describe('HeaderActionsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render menu items when create menu is opened', async () => {
|
it('should render menu items when create menu is opened', async () => {
|
||||||
spyOn(component, 'isPersonalFilesRoute').and.returnValue(true);
|
spyOnProperty(router, 'url').and.returnValue('/personal-files');
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
@@ -112,7 +115,7 @@ describe('HeaderActionsComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should render menu items when upload menu is opened', async () => {
|
it('should render menu items when upload menu is opened', async () => {
|
||||||
spyOn(component, 'isPersonalFilesRoute').and.returnValue(true);
|
spyOnProperty(router, 'url').and.returnValue('/personal-files');
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
await fixture.whenStable();
|
await fixture.whenStable();
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, OnDestroy, ViewEncapsulation } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { ContentManagementService } from '../../services/content-management.service';
|
import { ContentManagementService } from '../../services/content-management.service';
|
||||||
@@ -36,53 +36,37 @@ import { SetCurrentFolderAction, AppStore } from '@alfresco/aca-shared/store';
|
|||||||
styleUrls: ['./header-actions.component.scss'],
|
styleUrls: ['./header-actions.component.scss'],
|
||||||
encapsulation: ViewEncapsulation.None
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class HeaderActionsComponent extends PageComponent implements OnInit, OnDestroy {
|
export class HeaderActionsComponent extends PageComponent implements OnDestroy {
|
||||||
constructor(private router: Router, store: Store<AppStore>, content: ContentManagementService, extensions: AppExtensionService) {
|
constructor(private router: Router, store: Store<AppStore>, content: ContentManagementService, extensions: AppExtensionService) {
|
||||||
super(store, extensions, content);
|
super(store, extensions, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
super.ngOnInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.store.dispatch(new SetCurrentFolderAction(null));
|
this.store.dispatch(new SetCurrentFolderAction(null));
|
||||||
super.ngOnDestroy();
|
super.ngOnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
isPersonalFilesRoute(): boolean {
|
private isPersonalFilesRoute(): boolean {
|
||||||
return this.router.url.includes('/personal-files');
|
return this.router.url.includes('/personal-files');
|
||||||
}
|
}
|
||||||
|
|
||||||
isFavoriteLibrariesRoute(): boolean {
|
private isFavoriteLibrariesRoute(): boolean {
|
||||||
return this.router.url.includes('/favorite/libraries');
|
return this.router.url.includes('/favorite/libraries');
|
||||||
}
|
}
|
||||||
|
|
||||||
isLibrariesRoute(): boolean {
|
private isLibrariesRoute(): boolean {
|
||||||
return this.router.url.includes('/libraries');
|
return this.router.url.includes('/libraries');
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowCreateButton(): boolean {
|
canShowCreateButton(): boolean {
|
||||||
if (this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute()) {
|
return this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowUploadButton(): boolean {
|
canShowUploadButton(): boolean {
|
||||||
if (this.isPersonalFilesRoute()) {
|
return this.isPersonalFilesRoute();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canShowSearchSeparator(): boolean {
|
canShowSearchSeparator(): boolean {
|
||||||
if (this.isPersonalFilesRoute() || this.isFavoriteLibrariesRoute() || this.isLibrariesRoute()) {
|
return this.canShowUploadButton() || this.canShowCreateButton();
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user