mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
feat: fix DsoEditMenuSectionComponent test
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { MenuServiceStub } from '../../../testing/menu-service.stub';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MenuService } from '../../../menu/menu.service';
|
||||
import { CSSVariableService } from '../../../sass-helper/css-variable.service';
|
||||
import { CSSVariableServiceStub } from '../../../testing/css-variable-service.stub';
|
||||
import { Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { RouterStub } from '../../../testing/router.stub';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { Component } from '@angular/core';
|
||||
@@ -12,23 +11,31 @@ import { By } from '@angular/platform-browser';
|
||||
import { DsoEditMenuSectionComponent } from './dso-edit-menu-section.component';
|
||||
import { OnClickMenuItemModel } from '../../../menu/menu-item/models/onclick.model';
|
||||
import { MenuItemType } from 'src/app/shared/menu/menu-item-type.model';
|
||||
import { ActivatedRouteStub } from '../../../testing/active-router.stub';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
function initAsync(dummySectionText: { visible: boolean; icon: string; active: boolean; model: { disabled: boolean; text: string; type: MenuItemType }; id: string }, menuService: MenuServiceStub) {
|
||||
function initAsync(dummySectionText: {
|
||||
visible: boolean;
|
||||
icon: string;
|
||||
active: boolean;
|
||||
model: { disabled: boolean; text: string; type: MenuItemType };
|
||||
id: string
|
||||
}, menuService: MenuServiceStub) {
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), DsoEditMenuSectionComponent, TestComponent],
|
||||
providers: [
|
||||
{ provide: 'sectionDataProvider', useValue: dummySectionText },
|
||||
{ provide: MenuService, useValue: menuService },
|
||||
{ provide: CSSVariableService, useClass: CSSVariableServiceStub },
|
||||
{ provide: Router, useValue: new RouterStub() },
|
||||
]
|
||||
}).overrideComponent(DsoEditMenuSectionComponent, {
|
||||
set: {
|
||||
entryComponents: [TestComponent]
|
||||
}
|
||||
})
|
||||
.compileComponents();
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
DsoEditMenuSectionComponent,
|
||||
TestComponent
|
||||
],
|
||||
providers: [
|
||||
{provide: 'sectionDataProvider', useValue: dummySectionText},
|
||||
{provide: MenuService, useValue: menuService},
|
||||
{provide: CSSVariableService, useClass: CSSVariableServiceStub},
|
||||
{provide: Router, useValue: new RouterStub()},
|
||||
{provide: ActivatedRoute, useValue: new ActivatedRouteStub() },
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -61,7 +68,6 @@ describe('DsoEditMenuSectionComponent', () => {
|
||||
},
|
||||
icon: iconString
|
||||
};
|
||||
|
||||
const dummySectionClick = {
|
||||
id: 'dummy',
|
||||
active: false,
|
||||
@@ -77,6 +83,7 @@ describe('DsoEditMenuSectionComponent', () => {
|
||||
|
||||
describe('text model', () => {
|
||||
initAsync(dummySectionText, menuService);
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(menuService, 'getSubSectionsByParentID').and.returnValue(observableOf([]));
|
||||
fixture = TestBed.createComponent(DsoEditMenuSectionComponent);
|
||||
@@ -93,6 +100,7 @@ describe('DsoEditMenuSectionComponent', () => {
|
||||
const button = fixture.debugElement.query(By.css('.btn-dark'));
|
||||
expect(button.nativeElement.innerHTML).toContain('fa-' + iconString);
|
||||
});
|
||||
|
||||
describe('when the section model in a disabled link or text', () => {
|
||||
it('should show just the button', () => {
|
||||
const textButton = fixture.debugElement.query(By.css('div div button'));
|
||||
|
Reference in New Issue
Block a user