]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/core/event.spec.ts
LP1806087 Angular catalog Ang7 & lint repairs
[Evergreen.git] / Open-ILS / src / eg2 / src / app / core / event.spec.ts
1 import {EventService} from './event.service';
2
3 describe('EventService', () => {
4     let service: EventService;
5     beforeEach(() => {
6         service = new EventService();
7     });
8
9     const evt = {
10         ilsevent: '12345',
11         pid: '12345',
12         desc: 'Test Event Description',
13         payload: {test : 'xyz'},
14         textcode: 'TEST_EVENT',
15         servertime: 'Wed Nov 6 16:05:50 2013'
16     };
17
18     it('should parse an event object', () => {
19         expect(service.parse(evt)).not.toBe(null);
20     });
21
22     it('should not parse a non-event', () => {
23         expect(service.parse({})).toBe(null);
24     });
25
26     it('should not parse a non-event', () => {
27         expect(service.parse({abc : '123'})).toBe(null);
28     });
29
30     it('should not parse a non-event', () => {
31         expect(service.parse([])).toBe(null);
32     });
33
34     it('should not parse a non-event', () => {
35         expect(service.parse('STRING')).toBe(null);
36     });
37
38     it('should not parse a non-event', () => {
39         expect(service.parse(true)).toBe(null);
40     });
41
42     it('should stringify an event', () => {
43         expect(service.parse(evt).toString()).toBe(
44             'Event: 12345:TEST_EVENT -> Test Event Description');
45     });
46
47 });