mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 15:03:07 +00:00
Notifications test final
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
|
||||
import { NotificationsService } from '../notifications.service';
|
||||
import { notificationsReducer } from '../notifications.reducers';
|
||||
import { Store, StoreModule } from '@ngrx/store';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { NotificationsBoardComponent } from './notifications-board.component';
|
||||
import { AppState } from '../../../app.reducer';
|
||||
import { NotificationComponent } from '../notification/notification.component';
|
||||
import { Notification } from '../models/notification.model';
|
||||
import { NotificationType } from '../models/notification-type';
|
||||
import { uniqueId } from 'lodash';
|
||||
|
||||
describe('LoadingComponent (inline template)', () => {
|
||||
let comp: NotificationsBoardComponent;
|
||||
let fixture: ComponentFixture<NotificationsBoardComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
BrowserAnimationsModule,
|
||||
StoreModule.forRoot({notificationsReducer})],
|
||||
declarations: [NotificationsBoardComponent, NotificationComponent], // declare the test component
|
||||
providers: [
|
||||
NotificationsService,
|
||||
ChangeDetectorRef]
|
||||
}).compileComponents(); // compile template and css
|
||||
}));
|
||||
|
||||
beforeEach(inject([NotificationsService, Store], (service: NotificationsService, store: Store<AppState>) => {
|
||||
store
|
||||
.subscribe((state) => {
|
||||
const notifications = [
|
||||
new Notification(uniqueId(), NotificationType.Success, 'title1', 'content1'),
|
||||
new Notification(uniqueId(), NotificationType.Info, 'title2', 'content2')
|
||||
];
|
||||
state.notifications = notifications;
|
||||
});
|
||||
|
||||
fixture = TestBed.createComponent(NotificationsBoardComponent);
|
||||
comp = fixture.componentInstance;
|
||||
comp.options = {
|
||||
rtl: false,
|
||||
position: ['top', 'right'],
|
||||
maxStack: 5
|
||||
};
|
||||
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should create', () => {
|
||||
expect(comp).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should be 2 notifications', () => {
|
||||
expect(comp.notifications.length).toBe(2);
|
||||
});
|
||||
|
||||
})
|
||||
;
|
Reference in New Issue
Block a user