LP1754364-wip collab/sandbergja/lp1754364-timezone-dropdown
authorJane Sandberg <js7389@princeton.edu>
Wed, 17 May 2023 23:39:21 +0000 (16:39 -0700)
committerJane Sandberg <js7389@princeton.edu>
Wed, 17 May 2023 23:39:21 +0000 (16:39 -0700)
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Open-ILS/src/eg2/src/app/share/util/timezone.spec.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/share/util/timezone.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/edit-org-unit-setting-dialog.component.spec.ts [new file with mode: 0644]
Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/edit-org-unit-setting-dialog.component.ts

diff --git a/Open-ILS/src/eg2/src/app/share/util/timezone.spec.ts b/Open-ILS/src/eg2/src/app/share/util/timezone.spec.ts
new file mode 100644 (file)
index 0000000..419b636
--- /dev/null
@@ -0,0 +1,11 @@
+import { Timezone } from "./timezone";
+
+fdescribe('timezone utility', () => {
+  it('includes valid timezones', () => {
+    expect(new Timezone().values()).toContain('America/Chicago');
+    expect(new Timezone().values()).toContain('America/New_York');
+  });
+  it('does not include invalid timezones', () => {
+    expect(new Timezone().values()).not.toContain('MARGARITA TIME!!!');
+  });
+});
diff --git a/Open-ILS/src/eg2/src/app/share/util/timezone.ts b/Open-ILS/src/eg2/src/app/share/util/timezone.ts
new file mode 100644 (file)
index 0000000..5c0bb90
--- /dev/null
@@ -0,0 +1,7 @@
+import * as moment from "moment";
+
+export class Timezone {
+    values() {
+        return moment.tz.names();
+    }
+}
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/edit-org-unit-setting-dialog.component.spec.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/edit-org-unit-setting-dialog.component.spec.ts
new file mode 100644 (file)
index 0000000..c149900
--- /dev/null
@@ -0,0 +1,23 @@
+import { NgbModal } from "@ng-bootstrap/ng-bootstrap";
+import { EditOuSettingDialogComponent } from "./edit-org-unit-setting-dialog.component";
+
+const mockNgbModal = jasmine.createSpyObj<NgbModal>(['open']);
+let component: EditOuSettingDialogComponent;
+
+fdescribe('EditOuSettingDialogComponent', () => {
+    beforeEach(() => {
+        component = new EditOuSettingDialogComponent(mockNgbModal);
+    })
+    describe('inputType()', () => {
+        it('gets its value from the entry dataType', () => {
+            component.entry = {dataType: 'bool'}
+            expect(component.inputType()).toEqual('bool');    
+        });
+    });
+    describe('inputType()', () => {
+        it('returns timezone if the setting name is lib.timezone', () => {
+            component.entry = {dataType: 'string', name: 'lib.timezone'}
+            expect(component.inputType()).toEqual('timezone');    
+        });
+    });
+})
index 13ef179..0dd43bb 100644 (file)
@@ -28,6 +28,9 @@ export class EditOuSettingDialogComponent extends DialogComponent {
     }
 
     inputType() {
+        if (this.entry.name === 'lib.timezone') {
+            return 'timezone';
+        }
         return this.entry.dataType;
     }