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 let pcrudServiceStub: Partial<PcrudService>;
13 navigate: jasmine.createSpy('navigate')
16 pcrudServiceStub = {};
17 cookieServiceStub = {};
18 pcrudServiceStub = {};
19 cookieServiceStub = {};
20 printServiceStub = {};
21 TestBed.configureTestingModule({
23 ReservationActionsService,
24 { provide: Router, useValue: routerSpy },
25 { provide: PcrudService, useValue: pcrudServiceStub },
26 { provide: CookieService, useValue: cookieServiceStub },
27 { provide: PrintService, useValue: printServiceStub }
30 service = TestBed.get(ReservationActionsService);
32 it('can open the manage by barcode route', () => {
33 service.manageReservationsByResource('barcode123');
34 expect(routerSpy.navigate).toHaveBeenCalledWith(
35 ['/staff', 'booking', 'manage_reservations', 'by_resource', 'barcode123']);
37 it('recognizes 3 as one unique value', () => {
38 expect(service.notOneUniqueSelected([3])).toBe(false);
40 it('recognizes 1 1 as one unique value', () => {
41 expect(service.notOneUniqueSelected([1, 1])).toBe(false);
43 it('recognizes 2 3 as more than one unique value', () => {
44 expect(service.notOneUniqueSelected([2, 3])).toBe(true);