]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/booking/reservation-actions.spec.ts
10f8549a52550e83fed0790857cca3f0b7034208
[Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / booking / reservation-actions.spec.ts
1 import { TestBed } from '@angular/core/testing';
2 import { Router } from '@angular/router';
3 import { PcrudService } from '@eg/core/pcrud.service';
4 import { ReservationActionsService } from './reservation-actions.service';
5 describe('ReservationActionsService', () => {
6     let service: ReservationActionsService;
7     const routerSpy = {
8         navigate: jasmine.createSpy('navigate')
9     };
10     beforeEach(() => {
11         const pcrudServiceStub = {};
12         TestBed.configureTestingModule({
13             providers: [
14                 ReservationActionsService,
15                 { provide: Router, useValue: routerSpy },
16                 { provide: PcrudService, useValue: pcrudServiceStub }
17             ]
18         });
19         service = TestBed.get(ReservationActionsService);
20     });
21     it('can open the manage by barcode route', () => {
22         service.manageReservationsByResource('barcode123');
23         expect(routerSpy.navigate).toHaveBeenCalledWith(
24             ['/staff', 'booking', 'manage_reservations', 'by_resource', 'barcode123']);
25     });
26     it('recognizes 3 as one unique value', () => {
27         expect(service.notOneUniqueSelected([3])).toBe(false);
28     });
29     it('recognizes 1 1 as one unique value', () => {
30         expect(service.notOneUniqueSelected([1, 1])).toBe(false);
31     });
32     it('recognizes 2 3 as more than one unique value', () => {
33         expect(service.notOneUniqueSelected([2, 3])).toBe(true);
34     });
35 });