Skip to content
Snippets Groups Projects
Commit 5ab1062a authored by Giuseppe's avatar Giuseppe
Browse files

Fixed NotificationsService and NotificationComponent tests

parent 6f4b9fc8
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,9 @@ import { NotificationOptions } from '../models/notification-options.model';
import { INotificationBoardOptions } from '../../../../config/notifications-config.interfaces';
import { GlobalConfig } from '../../../../config/global-config.interface';
import { Notification } from '../models/notification.model';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { MockTranslateLoader } from '../../mocks/mock-translate-loader';
import { GLOBAL_CONFIG } from '../../../../config';
describe('NotificationComponent', () => {
......@@ -39,18 +42,28 @@ describe('NotificationComponent', () => {
animate: 'scale'
}as INotificationBoardOptions,
} as any;
const service = new NotificationsService(envConfig, store);
TestBed.configureTestingModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
StoreModule.forRoot({notificationsReducer})],
StoreModule.forRoot({notificationsReducer}),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: MockTranslateLoader
}
})],
declarations: [NotificationComponent], // declare the test component
providers: [
{ provide: NotificationsService, useValue: service },
ChangeDetectorRef]
{ provide: GLOBAL_CONFIG, useValue: envConfig },
{ provide: Store, useValue: store },
ChangeDetectorRef,
NotificationsService,
TranslateService,
]
}).compileComponents(); // compile template and css
}));
beforeEach(() => {
......
......@@ -10,36 +10,50 @@ import { NewNotificationAction, RemoveAllNotificationsAction, RemoveNotification
import { Notification } from './models/notification.model';
import { NotificationType } from './models/notification-type';
import { GlobalConfig } from '../../../config/global-config.interface';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { MockTranslateLoader } from '../mocks/mock-translate-loader';
import { GLOBAL_CONFIG } from '../../../config';
describe('NotificationsService test', () => {
const store: Store<Notification> = jasmine.createSpyObj('store', {
dispatch: {},
select: Observable.of(true)
});
let service;
let service: NotificationsService;
let envConfig: GlobalConfig;
envConfig = {
notifications: {
rtl: false,
position: ['top', 'right'],
maxStack: 8,
timeOut: 5000,
clickToClose: true,
animate: 'scale'
},
} as any;
beforeEach(async () => {
TestBed.configureTestingModule({
declarations: [NotificationComponent, NotificationsBoardComponent],
providers: [NotificationsService],
imports: [
StoreModule.forRoot({notificationsReducer}),
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useClass: MockTranslateLoader
}
})
],
declarations: [NotificationComponent, NotificationsBoardComponent],
providers: [
{ provide: GLOBAL_CONFIG, useValue: envConfig },
{ provide: Store, useValue: store },
NotificationsService,
TranslateService
]
});
envConfig = {
notifications: {
rtl: false,
position: ['top', 'right'],
maxStack: 8,
timeOut: 5000,
clickToClose: true,
animate: 'scale'
},
} as any;
service = new NotificationsService(envConfig, store);
service = TestBed.get(NotificationsService);
});
it('Success method should dispatch NewNotificationAction with proper parameter', () => {
......
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