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';
8 let netService: NetService;
9 let authService: AuthService;
10 let evtService: EventService;
11 let storeService: StoreService;
14 evtService = new EventService();
15 storeService = new StoreService(null /* CookieService */);
16 netService = new NetService(evtService);
17 authService = new AuthService(evtService, netService, storeService);
20 describe('PatronBarcodeValidator', () => {
21 it('should not throw an error if there is exactly 1 match', () => {
22 const pbv = new PatronBarcodeValidator(authService, netService);
23 pbv['parseActorCall'](of(1))
25 expect(val).toBeNull();
28 it('should throw an error if there is more than 1 match', () => {
29 const pbv = new PatronBarcodeValidator(authService, netService);
30 pbv['parseActorCall'](of(1, 2, 3))
32 expect(val).not.toBeNull();
35 it('should throw an error if there is no match', () => {
36 const pbv = new PatronBarcodeValidator(authService, netService);
37 pbv['parseActorCall'](of())
39 expect(val).not.toBeNull();