LP2000482: Get tests passing
authorJane Sandberg <js7389@princeton.edu>
Tue, 25 Apr 2023 13:23:30 +0000 (06:23 -0700)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 27 Apr 2023 10:41:58 +0000 (10:41 +0000)
* Update karma config
* Update Patron Barcode Validator directive due to a breaking change in rxjs single()
* Update test assertion to match new ar-JO localization

Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>

Open-ILS/src/eg2/angular.json
Open-ILS/src/eg2/src/app/core/format.spec.ts
Open-ILS/src/eg2/src/app/share/validators/patron_barcode_validator.directive.ts
Open-ILS/src/eg2/src/test.ts

index 349580f..53c6a0e 100644 (file)
@@ -90,9 +90,8 @@
         "test": {
           "builder": "@angular-devkit/build-angular:karma",
           "options": {
-            "main": "src/test.ts",
             "karmaConfig": "./karma.conf.js",
-            "polyfills": "src/polyfills.ts",
+            "polyfills": ["zone.js", "zone.js/testing", "src/polyfills.ts"],
             "tsConfig": "src/tsconfig.spec.json",
             "scripts": [],
             "styles": [
index 40cbb29..f254397 100644 (file)
@@ -132,7 +132,7 @@ describe('FormatService', () => {
     it('should transform long Angular format strings to a valid MomentJS one using Angular locale ar-JO', () => {
         registerLocaleData(localeArJO);
         const momentVersion = service['makeFormatParseable']('long', 'ar-JO');
-        expect(momentVersion).toBe('D MMMM Y h:mm:ss a [GMT]Z');
+        expect(momentVersion).toBe('D MMMM Y في h:mm:ss a [GMT]Z');
     });
     it('can create a valid Momentjs object given a valid datetime string and correct format', () => {
         const moment = service['momentize']('7/3/12, 6:06 PM', 'M/D/YY, h:mm a', 'Africa/Addis_Ababa', false);
index 0910bf3..6df8251 100644 (file)
@@ -1,8 +1,8 @@
 import { Directive, forwardRef } from '@angular/core';
-import { NG_VALIDATORS, NG_ASYNC_VALIDATORS, AbstractControl, ValidationErrors, AsyncValidator, FormControl } from '@angular/forms';
+import { NG_ASYNC_VALIDATORS, AsyncValidator, FormControl } from '@angular/forms';
 import {NetService} from '@eg/core/net.service';
 import {AuthService} from '@eg/core/auth.service';
-import {EmptyError, Observable, of} from 'rxjs';
+import {EmptyError, Observable, SequenceError, of} from 'rxjs';
 import {single, switchMap, catchError} from 'rxjs/operators';
 import {Injectable} from '@angular/core';
 
@@ -29,7 +29,7 @@ export class PatronBarcodeValidator implements AsyncValidator {
         catchError((err) => {
             if (err instanceof EmptyError) {
                 return of({ patronBarcode: 'No patron found with that barcode' });
-            } else if ('Sequence contains more than one element' === err) {
+            } else if (err instanceof SequenceError) {
                 return of({ patronBarcode: 'Barcode matches more than one patron' });
             }
         }));
index cd612ee..f0eaf33 100644 (file)
@@ -24,9 +24,5 @@ getTestBed().initTestEnvironment(
   BrowserDynamicTestingModule,
   platformBrowserDynamicTesting()
 );
-// Then we find all the tests.
-const context = require.context('./', true, /\.spec\.ts$/);
-// And load the modules.
-context.keys().map(context);
 // Finally, start Karma to run the tests.
 __karma__.start();