]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/booking/schedule-grid.spec.ts
LP1816475: Booking module refresh
[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             'barcode1': [{patronLabel: 'Joe', patronId: 1, reservationId: 3}],
26             'barcode2': [{patronLabel: 'Jill', patronId: 2, reservationId: 5}],
27             'barcode3': [{patronLabel: 'James', patronId: 3, reservationId: 12},
28                 {patronLabel: 'Juanes', patronId: 4, reservationId: 18}]
29         };
30         expect(service.resourceAvailabilityIcon(busyRow, 3).icon).toBe('event_busy');
31     });
32
33     it('should recognize when a row has some availability', () => {
34         const rowWithAvailability: ScheduleRow = {
35             'time': Moment(),
36             'barcode3': [{patronLabel: 'James', patronId: 3, reservationId: 11},
37                 {patronLabel: 'Juanes', patronId: 4, reservationId: 17}]
38         };
39         expect(service.resourceAvailabilityIcon(rowWithAvailability, 3).icon).toBe('event_available');
40     });
41
42     it('should recognize 4 February 2019 as a Monday', () => {
43         const date = new Date(2019, 1, 4);
44         expect(service['evergreenStyleDow'](date)).toBe('dow_0');
45     });
46
47     it('should recognize 3 February 2019 as a Sunday', () => {
48         const date = new Date(2019, 1, 3);
49         expect(service['evergreenStyleDow'](date)).toBe('dow_6');
50     });
51 });