]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/booking/schedule-grid.spec.ts
LP#1884787: update Angular staff client to work with momement-timezone >= 0.5.29
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / booking / schedule-grid.spec.ts
1 import { TestBed } from '@angular/core/testing';
2 import { AuthService } from '@eg/core/auth.service';
3 import { PcrudService } from '@eg/core/pcrud.service';
4 import { ScheduleGridService, ScheduleRow } from './schedule-grid.service';
5 import * as moment from 'moment-timezone';
6
7 describe('ScheduleGridService', () => {
8     let service: ScheduleGridService;
9     beforeEach(() => {
10         const authServiceStub = {};
11         const pcrudServiceStub = {};
12         TestBed.configureTestingModule({
13             providers: [
14                 ScheduleGridService,
15                 { provide: AuthService, useValue: authServiceStub },
16                 { provide: PcrudService, useValue: pcrudServiceStub }
17             ]
18         });
19         service = TestBed.get(ScheduleGridService);
20     });
21
22     it('should recognize when a row is completely busy', () => {
23         const busyRow: ScheduleRow = {
24             'time': moment(),
25             'patrons': {
26                 'barcode1': [{patronLabel: 'Joe', patronId: 1, reservationId: 3}],
27                 'barcode2': [{patronLabel: 'Jill', patronId: 2, reservationId: 5}],
28                 'barcode3': [{patronLabel: 'James', patronId: 3, reservationId: 12},
29                              {patronLabel: 'Juanes', patronId: 4, reservationId: 18}]
30              }
31         };
32         expect(service.resourceAvailabilityIcon(busyRow, 3).icon).toBe('event_busy');
33     });
34
35     it('should recognize when a row has some availability', () => {
36         const rowWithAvailability: ScheduleRow = {
37             'time': moment(),
38             'patrons': {
39                 'barcode3': [{patronLabel: 'James', patronId: 3, reservationId: 11},
40                              {patronLabel: 'Juanes', patronId: 4, reservationId: 17}]
41             }
42         };
43         expect(service.resourceAvailabilityIcon(rowWithAvailability, 3).icon).toBe('event_available');
44     });
45
46     it('should recognize 4 February 2019 as a Monday', () => {
47         const date = new Date(2019, 1, 4);
48         expect(service['evergreenStyleDow'](date)).toBe('dow_0');
49     });
50
51     it('should recognize 3 February 2019 as a Sunday', () => {
52         const date = new Date(2019, 1, 3);
53         expect(service['evergreenStyleDow'](date)).toBe('dow_6');
54     });
55 });