mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
74199: Lint and LGTM fixes + HoverClassDirective JSDocs and tests
This commit is contained in:
35
src/app/shared/hover-class.directive.spec.ts
Normal file
35
src/app/shared/hover-class.directive.spec.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Component, DebugElement } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { HoverClassDirective } from './hover-class.directive';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
@Component({
|
||||
template: `<div dsHoverClass="ds-hover"></div>`
|
||||
})
|
||||
class TestComponent { }
|
||||
|
||||
describe('HoverClassDirective', () => {
|
||||
let component: TestComponent;
|
||||
let fixture: ComponentFixture<TestComponent>;
|
||||
let el: DebugElement;
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.configureTestingModule({
|
||||
declarations: [TestComponent, HoverClassDirective]
|
||||
}).createComponent(TestComponent);
|
||||
|
||||
fixture.detectChanges();
|
||||
component = fixture.componentInstance;
|
||||
el = fixture.debugElement.query(By.css('div'));
|
||||
});
|
||||
|
||||
it('should add the class on mouseenter and remove on mouseleave', () => {
|
||||
el.triggerEventHandler('mouseenter', null);
|
||||
fixture.detectChanges();
|
||||
expect(el.nativeElement.classList).toContain('ds-hover');
|
||||
|
||||
el.triggerEventHandler('mouseleave', null);
|
||||
fixture.detectChanges();
|
||||
expect(el.nativeElement.classList).not.toContain('ds-hover');
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user