-
Notifications
You must be signed in to change notification settings - Fork 36
/
notification-service.spec.ts
39 lines (33 loc) · 1.6 KB
/
notification-service.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {TestBed, inject} from "@angular/core/testing";
import {TranslateModule} from "ng2-translate";
import {Observable} from "rxjs";
import {NotificationService} from "./notification-service";
import {NotificationsService} from "angular2-notifications";
describe('Service: NotificationService', () => {
let service: NotificationService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot()],
providers: [NotificationsService, NotificationService]
});
});
beforeEach(inject([NotificationService], (_service) => {
service = _service;
spyOn(service.translate, 'get').and.returnValue(Observable.of('translatedValue'));
}));
it('should get the success notification message', () => {
spyOn(service.notificationsService, 'success');
service.createNotification('success', 'title', 'content');
expect(service.notificationsService.success).toHaveBeenCalledWith('translatedValue', 'translatedValue');
});
it('should get the error notification message', () => {
spyOn(service.notificationsService, 'error');
service.createNotification('error', 'title', 'content');
expect(service.notificationsService.error).toHaveBeenCalledWith('translatedValue', 'translatedValue');
});
it('should get the info notification message', () => {
spyOn(service.notificationsService, 'info');
service.createNotification('info', 'title', 'content');
expect(service.notificationsService.info).toHaveBeenCalledWith('translatedValue', 'translatedValue');
});
});