2019-07-07 11:18:12 +05:30
|
|
|
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,
|
2021-11-11 11:23:49 +05:30
|
|
|
integrated: false,
|
2019-07-07 11:18:12 +05:30
|
|
|
token: '',
|
|
|
|
selectedProject: null,
|
|
|
|
};
|
|
|
|
const transformedEmptySettingsObject = {
|
|
|
|
api_host: null,
|
|
|
|
enabled: false,
|
2021-11-11 11:23:49 +05:30
|
|
|
integrated: false,
|
2019-07-07 11:18:12 +05:30
|
|
|
token: null,
|
|
|
|
project: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
expect(transformFrontendSettings(emptyFrontendSettingsObject)).toEqual(
|
|
|
|
transformedEmptySettingsObject,
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|