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';
7 describe('ScheduleGridService', () => {
8 let service: ScheduleGridService;
10 const authServiceStub = {};
11 const pcrudServiceStub = {};
12 TestBed.configureTestingModule({
15 { provide: AuthService, useValue: authServiceStub },
16 { provide: PcrudService, useValue: pcrudServiceStub }
19 service = TestBed.get(ScheduleGridService);
22 it('should recognize when a row is completely busy', () => {
23 const busyRow: ScheduleRow = {
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}]
32 expect(service.resourceAvailabilityIcon(busyRow, 3).icon).toBe('event_busy');
35 it('should recognize when a row has some availability', () => {
36 const rowWithAvailability: ScheduleRow = {
39 'barcode3': [{patronLabel: 'James', patronId: 3, reservationId: 11},
40 {patronLabel: 'Juanes', patronId: 4, reservationId: 17}]
43 expect(service.resourceAvailabilityIcon(rowWithAvailability, 3).icon).toBe('event_available');
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');
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');