-
diff --git a/src/app/shared/notifications/notification/notification.component.spec.ts b/src/app/shared/notifications/notification/notification.component.spec.ts
index cce9796a29..3e614e1378 100644
--- a/src/app/shared/notifications/notification/notification.component.spec.ts
+++ b/src/app/shared/notifications/notification/notification.component.spec.ts
@@ -1,4 +1,4 @@
-import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { async, ComponentFixture, inject, TestBed } from '@angular/core/testing';
import { BrowserModule, By } from '@angular/platform-browser';
import { ChangeDetectorRef, DebugElement } from '@angular/core';
@@ -6,9 +6,17 @@ import { NotificationComponent } from './notification.component';
import { NotificationsService } from '../notifications.service';
import { NotificationType } from '../models/notification-type';
import { notificationsReducer } from '../notifications.reducers';
-import { StoreModule } from '@ngrx/store';
+import { Store, StoreModule } from '@ngrx/store';
import { NotificationOptions } from '../models/notification-options.model';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
+import { Router } from '@angular/router';
+import { NotificationsServiceStub } from '../../testing/notifications-service-stub';
+import { AppState } from '../../../app.reducer';
+import { Observable } from 'rxjs/Observable';
+import { SearchPageComponent } from '../../../+search-page/search-page.component';
+import { INotificationBoardOptions } from '../../../../config/notifications-config.interfaces';
+import { GlobalConfig } from '../../../../config/global-config.interface';
+import { Notification } from '../models/notification.model';
describe('NotificationComponent', () => {
@@ -21,6 +29,22 @@ describe('NotificationComponent', () => {
let elType: HTMLElement;
beforeEach(async(() => {
+ const store: Store
= jasmine.createSpyObj('store', {
+ /* tslint:disable:no-empty */
+ notifications: []
+ });
+ const envConfig: GlobalConfig = {
+ notifications: {
+ rtl: false,
+ position: ['top', 'right'],
+ maxStack: 8,
+ timeOut: 5000,
+ clickToClose: true,
+ animate: 'scale'
+ }as INotificationBoardOptions,
+ } as any;
+ const service = new NotificationsService(envConfig, store);
+
TestBed.configureTestingModule({
imports: [
BrowserModule,
@@ -28,12 +52,12 @@ describe('NotificationComponent', () => {
StoreModule.forRoot({notificationsReducer})],
declarations: [NotificationComponent], // declare the test component
providers: [
- NotificationsService,
+ { provide: NotificationsService, useValue: service },
ChangeDetectorRef]
}).compileComponents(); // compile template and css
}));
- beforeEach(() => {
+ beforeEach(() => {
fixture = TestBed.createComponent(NotificationComponent);
comp = fixture.componentInstance;
comp.item = {
@@ -46,11 +70,11 @@ describe('NotificationComponent', () => {
fixture.detectChanges();
- deTitle = fixture.debugElement.query(By.css('.sn-title'));
+ deTitle = fixture.debugElement.query(By.css('.notification-title'));
elTitle = deTitle.nativeElement;
- deContent = fixture.debugElement.query(By.css('.sn-content'));
+ deContent = fixture.debugElement.query(By.css('.notification-content'));
elContent = deContent.nativeElement;
- elType = fixture.debugElement.query(By.css('.fa-info')).nativeElement;
+ elType = fixture.debugElement.query(By.css('.notification-icon')).nativeElement;
});
it('should create component', () => {
diff --git a/src/app/shared/notifications/notifications-board/notifications-board.component.spec.ts b/src/app/shared/notifications/notifications-board/notifications-board.component.spec.ts
index 808a404725..558ca9a067 100644
--- a/src/app/shared/notifications/notifications-board/notifications-board.component.spec.ts
+++ b/src/app/shared/notifications/notifications-board/notifications-board.component.spec.ts
@@ -13,6 +13,7 @@ import { Notification } from '../models/notification.model';
import { NotificationType } from '../models/notification-type';
import { uniqueId } from 'lodash';
import { INotificationBoardOptions } from '../../../../config/notifications-config.interfaces';
+import { NotificationsServiceStub } from '../../testing/notifications-service-stub';
describe('NotificationsBoardComponent', () => {
let comp: NotificationsBoardComponent;
@@ -26,7 +27,7 @@ describe('NotificationsBoardComponent', () => {
StoreModule.forRoot({notificationsReducer})],
declarations: [NotificationsBoardComponent, NotificationComponent], // declare the test component
providers: [
- NotificationsService,
+ { provide: NotificationsService, useClass: NotificationsServiceStub },
ChangeDetectorRef]
}).compileComponents(); // compile template and css
}));
diff --git a/src/app/shared/testing/notifications-service-stub.ts b/src/app/shared/testing/notifications-service-stub.ts
new file mode 100644
index 0000000000..5629a05a96
--- /dev/null
+++ b/src/app/shared/testing/notifications-service-stub.ts
@@ -0,0 +1,46 @@
+import { Observable } from 'rxjs/Observable';
+import { INotification } from '../notifications/models/notification.model';
+import { NotificationOptions } from '../notifications/models/notification-options.model';
+
+export class NotificationsServiceStub {
+
+ success(title: any = Observable.of(''),
+ content: any = Observable.of(''),
+ options: NotificationOptions = this.getDefaultOptions(),
+ html?: any): INotification {
+ return
+ }
+
+ error(title: any = Observable.of(''),
+ content: any = Observable.of(''),
+ options: NotificationOptions = this.getDefaultOptions(),
+ html?: any): INotification {
+ return
+ }
+
+ info(title: any = Observable.of(''),
+ content: any = Observable.of(''),
+ options: NotificationOptions = this.getDefaultOptions(),
+ html?: any): INotification {
+ return
+ }
+
+ warning(title: any = Observable.of(''),
+ content: any = Observable.of(''),
+ options: NotificationOptions = this.getDefaultOptions(),
+ html?: any): INotification {
+ return
+ }
+
+ remove(notification: INotification) {
+ return
+ }
+
+ removeAll() {
+ return
+ }
+
+ private getDefaultOptions(): NotificationOptions {
+ return new NotificationOptions();
+ }
+}