expandable-admin-sidebar-section.component.spec.ts (dspace-angular-dspace-7.0) | : | expandable-admin-sidebar-section.component.spec.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
skipping to change at line 13 | skipping to change at line 13 | |||
import { ExpandableAdminSidebarSectionComponent } from './expandable-admin-sideb ar-section.component'; | import { ExpandableAdminSidebarSectionComponent } from './expandable-admin-sideb ar-section.component'; | |||
import { MenuService } from '../../../shared/menu/menu.service'; | import { MenuService } from '../../../shared/menu/menu.service'; | |||
import { MenuServiceStub } from '../../../shared/testing/menu-service.stub'; | import { MenuServiceStub } from '../../../shared/testing/menu-service.stub'; | |||
import { CSSVariableService } from '../../../shared/sass-helper/sass-helper.serv ice'; | import { CSSVariableService } from '../../../shared/sass-helper/sass-helper.serv ice'; | |||
import { CSSVariableServiceStub } from '../../../shared/testing/css-variable-ser vice.stub'; | import { CSSVariableServiceStub } from '../../../shared/testing/css-variable-ser vice.stub'; | |||
import { of as observableOf } from 'rxjs'; | import { of as observableOf } from 'rxjs'; | |||
import { Component } from '@angular/core'; | import { Component } from '@angular/core'; | |||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | |||
import { By } from '@angular/platform-browser'; | import { By } from '@angular/platform-browser'; | |||
import { TranslateModule } from '@ngx-translate/core'; | import { TranslateModule } from '@ngx-translate/core'; | |||
import { Router } from '@angular/router'; | ||||
import { RouterStub } from '../../../shared/testing/router.stub'; | ||||
describe('ExpandableAdminSidebarSectionComponent', () => { | describe('ExpandableAdminSidebarSectionComponent', () => { | |||
let component: ExpandableAdminSidebarSectionComponent; | let component: ExpandableAdminSidebarSectionComponent; | |||
let fixture: ComponentFixture<ExpandableAdminSidebarSectionComponent>; | let fixture: ComponentFixture<ExpandableAdminSidebarSectionComponent>; | |||
const menuService = new MenuServiceStub(); | const menuService = new MenuServiceStub(); | |||
const iconString = 'test'; | const iconString = 'test'; | |||
beforeEach(waitForAsync(() => { | beforeEach(waitForAsync(() => { | |||
TestBed.configureTestingModule({ | TestBed.configureTestingModule({ | |||
imports: [NoopAnimationsModule, TranslateModule.forRoot()], | imports: [NoopAnimationsModule, TranslateModule.forRoot()], | |||
declarations: [ExpandableAdminSidebarSectionComponent, TestComponent], | declarations: [ExpandableAdminSidebarSectionComponent, TestComponent], | |||
providers: [ | providers: [ | |||
{ provide: 'sectionDataProvider', useValue: { icon: iconString } }, | { provide: 'sectionDataProvider', useValue: { icon: iconString } }, | |||
{ provide: MenuService, useValue: menuService }, | { provide: MenuService, useValue: menuService }, | |||
{ provide: CSSVariableService, useClass: CSSVariableServiceStub }, | { provide: CSSVariableService, useClass: CSSVariableServiceStub }, | |||
{ provide: Router, useValue: new RouterStub() }, | ||||
] | ] | |||
}).overrideComponent(ExpandableAdminSidebarSectionComponent, { | }).overrideComponent(ExpandableAdminSidebarSectionComponent, { | |||
set: { | set: { | |||
entryComponents: [TestComponent] | entryComponents: [TestComponent] | |||
} | } | |||
}) | }) | |||
.compileComponents(); | .compileComponents(); | |||
})); | })); | |||
beforeEach(() => { | beforeEach(() => { | |||
skipping to change at line 49 | skipping to change at line 52 | |||
component = fixture.componentInstance; | component = fixture.componentInstance; | |||
spyOn(component as any, 'getMenuItemComponent').and.returnValue(TestComponen t); | spyOn(component as any, 'getMenuItemComponent').and.returnValue(TestComponen t); | |||
fixture.detectChanges(); | fixture.detectChanges(); | |||
}); | }); | |||
it('should create', () => { | it('should create', () => { | |||
expect(component).toBeTruthy(); | expect(component).toBeTruthy(); | |||
}); | }); | |||
it('should set the right icon', () => { | it('should set the right icon', () => { | |||
const icon = fixture.debugElement.query(By.css('.icon-wrapper')).query(By.cs s('i.fas')); | const icon = fixture.debugElement.query(By.css('.shortcut-icon > i.fas')); | |||
expect(icon.nativeElement.getAttribute('class')).toContain('fa-' + iconStrin g); | expect(icon.nativeElement.getAttribute('class')).toContain('fa-' + iconStrin g); | |||
}); | }); | |||
describe('when the icon is clicked', () => { | ||||
beforeEach(() => { | ||||
spyOn(menuService, 'toggleActiveSection'); | ||||
const sidebarToggler = fixture.debugElement.query(By.css('a.shortcut-icon' | ||||
)); | ||||
sidebarToggler.triggerEventHandler('click', { | ||||
preventDefault: () => {/**/ | ||||
} | ||||
}); | ||||
}); | ||||
it('should call toggleActiveSection on the menuService', () => { | ||||
expect(menuService.toggleActiveSection).toHaveBeenCalled(); | ||||
}); | ||||
}); | ||||
describe('when the header text is clicked', () => { | describe('when the header text is clicked', () => { | |||
beforeEach(() => { | beforeEach(() => { | |||
spyOn(menuService, 'toggleActiveSection'); | spyOn(menuService, 'toggleActiveSection'); | |||
const sidebarToggler = fixture.debugElement.query(By.css('.sidebar-collaps ible')).query(By.css('a')); | const sidebarToggler = fixture.debugElement.query(By.css('.sidebar-section > div.nav-item')); | |||
sidebarToggler.triggerEventHandler('click', { | sidebarToggler.triggerEventHandler('click', { | |||
preventDefault: () => {/**/ | preventDefault: () => {/**/ | |||
} | } | |||
}); | }); | |||
}); | }); | |||
it('should call toggleActiveSection on the menuService', () => { | it('should call toggleActiveSection on the menuService', () => { | |||
expect(menuService.toggleActiveSection).toHaveBeenCalled(); | expect(menuService.toggleActiveSection).toHaveBeenCalled(); | |||
}); | }); | |||
}); | }); | |||
End of changes. 5 change blocks. | ||||
18 lines changed or deleted | 5 lines changed or added |