summaryrefslogtreecommitdiff
path: root/spec/frontend/error_tracking_settings/utils_spec.js
blob: 4b144f7daf1e6f7a023b65a1ba3b94e8231cb85d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { transformFrontendSettings } from '~/error_tracking_settings/utils';
import { sampleFrontendSettings, transformedSettings } from './mock';

describe('error tracking settings utils', () => {
  describe('data transform functions', () => {
    it('should transform settings successfully for the backend', () => {
      expect(transformFrontendSettings(sampleFrontendSettings)).toEqual(transformedSettings);
    });

    it('should transform empty values in the settings object to null', () => {
      const emptyFrontendSettingsObject = {
        apiHost: '',
        enabled: false,
        token: '',
        selectedProject: null,
      };
      const transformedEmptySettingsObject = {
        api_host: null,
        enabled: false,
        token: null,
        project: null,
      };

      expect(transformFrontendSettings(emptyFrontendSettingsObject)).toEqual(
        transformedEmptySettingsObject,
      );
    });
  });
});