Skip to content
Snippets Groups Projects
Commit 7d38976e authored by Giuseppe Digilio's avatar Giuseppe Digilio
Browse files

Fixed tests

parent 343e5e4f
No related branches found
No related tags found
No related merge requests found
......@@ -25,30 +25,30 @@
<div class="d-flex flex-column justify-content-center align-content-stretch">
<div class="p-2 mr-3" *ngIf="title">
<strong>
<div class="pl-1" *ngIf="titleIsTemplate; else regularTitle">
<div class="notification-title pl-1" *ngIf="titleIsTemplate; else regularTitle">
<ng-container *ngTemplateOutlet="title"></ng-container>
</div>
<ng-template #regularTitle>
<div class="pl-1" [innerHTML]="(title | async)"></div>
<div class="notification-title pl-1" [innerHTML]="(title | async)"></div>
</ng-template>
</strong>
</div>
<div class="p-2 mr-3" *ngIf="content">
<div class="pl-1" *ngIf="contentIsTemplate; else regularContent">
<div class="notification-content pl-1" *ngIf="contentIsTemplate; else regularContent">
<ng-container *ngTemplateOutlet="content"></ng-container>
</div>
<ng-template #regularContent>
<div class="pl-1" [innerHTML]="(content | async)"></div>
<div class="notification-content pl-1" [innerHTML]="(content | async)"></div>
</ng-template>
</div>
<div class="p-2 mr-3" *ngIf="item.html">
<div class="pl-1" *ngIf="htmlIsTemplate; else regularHtml">
<div class="notification-html pl-1" *ngIf="htmlIsTemplate; else regularHtml">
<ng-container *ngTemplateOutlet="html"></ng-container>
</div>
<ng-template #regularHtml>
<div class="pl-1" [innerHTML]="html"></div>
<div class="notification-html pl-1" [innerHTML]="html"></div>
</ng-template>
</div>
</div>
......
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<Notification> = 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', () => {
......
......@@ -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
}));
......
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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment