]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/settings.service.spec.ts
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / settings.service.spec.ts
index faae4237381b406d89af6c23037812de7f1181be..122f2691cfcd10ba6afbf4f742df4ad4413869d3 100644 (file)
@@ -8,6 +8,9 @@ describe('SettingsService', () => {
   let service: SettingsService;
   let httpTesting: HttpTestingController;
 
+  const exampleUrl = 'api/settings/something';
+  const exampleValue = 'http://localhost:3000';
+
   configureTestBed(
     {
       providers: [SettingsService],
@@ -60,15 +63,19 @@ describe('SettingsService', () => {
   });
 
   describe('isSettingConfigured', () => {
-    const exampleUrl = 'api/settings/something';
-    const exampleValue = 'http://localhost:3000';
     let increment: number;
 
     const testConfig = (url, value) => {
-      service.ifSettingConfigured(url, (setValue) => {
-        expect(setValue).toBe(value);
-        increment++;
-      });
+      service.ifSettingConfigured(
+        url,
+        (setValue) => {
+          expect(setValue).toBe(value);
+          increment++;
+        },
+        () => {
+          increment--;
+        }
+      );
     };
 
     const expectSettingsApiCall = (url: string, value: object, isSet: string) => {
@@ -77,7 +84,7 @@ describe('SettingsService', () => {
       expect(req.request.method).toBe('GET');
       req.flush(value);
       tick();
-      expect(increment).toBe(isSet !== '' ? 1 : 0);
+      expect(increment).toBe(isSet !== '' ? 1 : -1);
       expect(service['settings'][url]).toBe(isSet);
     };
 
@@ -112,4 +119,10 @@ describe('SettingsService', () => {
       expect(increment).toBe(2);
     }));
   });
+
+  it('should disable a set setting', () => {
+    service['settings'] = { [exampleUrl]: exampleValue };
+    service.disableSetting(exampleUrl);
+    expect(service['settings']).toEqual({ [exampleUrl]: '' });
+  });
 });