notifications-board.component.spec.ts (dspace-angular-dspace-7.0) | : | notifications-board.component.spec.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/t esting'; | import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/t esting'; | |||
import { BrowserModule } from '@angular/platform-browser'; | import { BrowserModule, By } from '@angular/platform-browser'; | |||
import { ChangeDetectorRef } from '@angular/core'; | import { ChangeDetectorRef } from '@angular/core'; | |||
import { NotificationsService } from '../notifications.service'; | import { NotificationsService } from '../notifications.service'; | |||
import { notificationsReducer } from '../notifications.reducers'; | import { notificationsReducer } from '../notifications.reducers'; | |||
import { Store, StoreModule } from '@ngrx/store'; | import { Store, StoreModule } from '@ngrx/store'; | |||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | |||
import { NotificationsBoardComponent } from './notifications-board.component'; | import { NotificationsBoardComponent } from './notifications-board.component'; | |||
import { AppState } from '../../../app.reducer'; | import { AppState } from '../../../app.reducer'; | |||
import { NotificationComponent } from '../notification/notification.component'; | import { NotificationComponent } from '../notification/notification.component'; | |||
import { Notification } from '../models/notification.model'; | import { Notification } from '../models/notification.model'; | |||
import { NotificationType } from '../models/notification-type'; | import { NotificationType } from '../models/notification-type'; | |||
import { uniqueId } from 'lodash'; | import { uniqueId } from 'lodash'; | |||
import { INotificationBoardOptions } from '../../../../config/notifications-conf ig.interfaces'; | import { INotificationBoardOptions } from '../../../../config/notifications-conf ig.interfaces'; | |||
import { NotificationsServiceStub } from '../../testing/notifications-service.st ub'; | import { NotificationsServiceStub } from '../../testing/notifications-service.st ub'; | |||
import { cold } from 'jasmine-marbles'; | ||||
export const bools = { f: false, t: true }; | ||||
describe('NotificationsBoardComponent', () => { | describe('NotificationsBoardComponent', () => { | |||
let comp: NotificationsBoardComponent; | let comp: NotificationsBoardComponent; | |||
let fixture: ComponentFixture<NotificationsBoardComponent>; | let fixture: ComponentFixture<NotificationsBoardComponent>; | |||
beforeEach(waitForAsync(() => { | beforeEach(waitForAsync(() => { | |||
TestBed.configureTestingModule({ | TestBed.configureTestingModule({ | |||
imports: [ | imports: [ | |||
BrowserModule, | BrowserModule, | |||
BrowserAnimationsModule, | BrowserAnimationsModule, | |||
skipping to change at line 70 | skipping to change at line 73 | |||
fixture.detectChanges(); | fixture.detectChanges(); | |||
})); | })); | |||
it('should create component', () => { | it('should create component', () => { | |||
expect(comp).toBeTruthy(); | expect(comp).toBeTruthy(); | |||
}); | }); | |||
it('should have two notifications', () => { | it('should have two notifications', () => { | |||
expect(comp.notifications.length).toBe(2); | expect(comp.notifications.length).toBe(2); | |||
expect(fixture.debugElement.queryAll(By.css('ds-notification')).length).toBe | ||||
(2); | ||||
}); | ||||
describe('notification countdown', () => { | ||||
let wrapper; | ||||
beforeEach(() => { | ||||
wrapper = fixture.debugElement.query(By.css('div.notifications-wrapper')); | ||||
}); | ||||
it('should not be paused by default', () => { | ||||
expect(comp.isPaused$).toBeObservable(cold('f', bools)); | ||||
}); | ||||
it('should pause on mouseenter', () => { | ||||
wrapper.triggerEventHandler('mouseenter'); | ||||
expect(comp.isPaused$).toBeObservable(cold('t', bools)); | ||||
}); | ||||
it('should resume on mouseleave', () => { | ||||
wrapper.triggerEventHandler('mouseenter'); | ||||
wrapper.triggerEventHandler('mouseleave'); | ||||
expect(comp.isPaused$).toBeObservable(cold('f', bools)); | ||||
}); | ||||
it('should be passed to all notifications', () => { | ||||
fixture.debugElement.queryAll(By.css('ds-notification')) | ||||
.map(node => node.componentInstance) | ||||
.forEach(notification => { | ||||
expect(notification.isPaused$).toEqual(comp.isPaused | ||||
$); | ||||
}); | ||||
}); | ||||
}); | }); | |||
}) | }) | |||
; | ; | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 40 lines changed or added |