2019-11-05 16:07:46 -05:00
|
|
|
import SentryConfig from '~/sentry/sentry_config';
|
|
|
|
import index from '~/sentry/index';
|
2017-04-04 09:58:45 -04:00
|
|
|
|
2019-11-05 16:07:46 -05:00
|
|
|
describe('SentryConfig options', () => {
|
|
|
|
const dsn = 'https://123@sentry.gitlab.test/123';
|
2017-05-19 16:13:57 -04:00
|
|
|
const currentUserId = 'currentUserId';
|
|
|
|
const gitlabUrl = 'gitlabUrl';
|
2019-04-07 15:21:52 -04:00
|
|
|
const environment = 'test';
|
2017-05-21 08:38:03 -04:00
|
|
|
const revision = 'revision';
|
2017-04-13 12:17:41 -04:00
|
|
|
let indexReturnValue;
|
2017-04-04 09:58:45 -04:00
|
|
|
|
2017-04-13 12:17:41 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
window.gon = {
|
2019-11-05 16:07:46 -05:00
|
|
|
sentry_dsn: dsn,
|
2019-04-07 15:21:52 -04:00
|
|
|
sentry_environment: environment,
|
2017-04-13 12:17:41 -04:00
|
|
|
current_user_id: currentUserId,
|
|
|
|
gitlab_url: gitlabUrl,
|
2017-05-21 08:38:03 -04:00
|
|
|
revision,
|
2017-04-13 12:17:41 -04:00
|
|
|
};
|
2017-04-04 09:58:45 -04:00
|
|
|
|
2017-05-21 08:38:03 -04:00
|
|
|
process.env.HEAD_COMMIT_SHA = revision;
|
2017-05-05 10:55:55 -04:00
|
|
|
|
2019-11-05 16:07:46 -05:00
|
|
|
jest.spyOn(SentryConfig, 'init').mockImplementation();
|
2017-04-13 12:17:41 -04:00
|
|
|
|
|
|
|
indexReturnValue = index();
|
|
|
|
});
|
|
|
|
|
2019-04-07 15:21:52 -04:00
|
|
|
it('should init with .sentryDsn, .currentUserId, .whitelistUrls and environment', () => {
|
2019-11-05 16:07:46 -05:00
|
|
|
expect(SentryConfig.init).toHaveBeenCalledWith({
|
|
|
|
dsn,
|
2017-04-13 12:17:41 -04:00
|
|
|
currentUserId,
|
2019-04-07 15:21:52 -04:00
|
|
|
whitelistUrls: [gitlabUrl, 'webpack-internal://'],
|
|
|
|
environment,
|
2017-05-21 08:38:03 -04:00
|
|
|
release: revision,
|
2017-05-19 16:13:57 -04:00
|
|
|
tags: {
|
2017-05-21 08:38:03 -04:00
|
|
|
revision,
|
2017-05-19 16:13:57 -04:00
|
|
|
},
|
2017-04-13 12:17:41 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-11-05 16:07:46 -05:00
|
|
|
it('should return SentryConfig', () => {
|
|
|
|
expect(indexReturnValue).toBe(SentryConfig);
|
2017-04-13 12:17:41 -04:00
|
|
|
});
|
2017-04-04 09:58:45 -04:00
|
|
|
});
|