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