]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/share/validators/patron_barcode_validator.directive.spec.ts
LP1615805 No inputs after submit in patron search (AngularJS)
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / share / validators / patron_barcode_validator.directive.spec.ts
1 import {PatronBarcodeValidator} from './patron_barcode_validator.directive';
2 import {of} from 'rxjs';
3 import {NetService} from '@eg/core/net.service';
4 import {AuthService} from '@eg/core/auth.service';
5 import {EventService} from '@eg/core/event.service';
6 import {StoreService} from '@eg/core/store.service';
7 import {HatchService} from '@eg/core/hatch.service';
8
9 let netService: NetService;
10 let authService: AuthService;
11 let evtService: EventService;
12 let storeService: StoreService;
13 let hatchService: HatchService;
14
15 beforeEach(() => {
16     evtService = new EventService();
17     hatchService = new HatchService();
18     storeService = new StoreService(null /* CookieService */, hatchService);
19     netService = new NetService(evtService);
20     authService = new AuthService(evtService, netService, storeService);
21 });
22
23 describe('PatronBarcodeValidator', () => {
24     it('should not throw an error if there is exactly 1 match', () => {
25         const pbv = new PatronBarcodeValidator(authService, netService);
26         pbv['parseActorCall'](of(1))
27             .subscribe((val) => {
28                 expect(val).toBeNull();
29             });
30     });
31     it('should throw an error if there is more than 1 match', () => {
32         const pbv = new PatronBarcodeValidator(authService, netService);
33         pbv['parseActorCall'](of(1, 2, 3))
34             .subscribe((val) => {
35                 expect(val).not.toBeNull();
36             });
37     });
38     it('should throw an error if there is no match', () => {
39         const pbv = new PatronBarcodeValidator(authService, netService);
40         pbv['parseActorCall'](of())
41             .subscribe((val) => {
42                 expect(val).not.toBeNull();
43             });
44     });
45 });
46