2019-12-26 22:10:19 +05:30
|
|
|
import SentryConfig from '~/sentry/sentry_config';
|
|
|
|
import index from '~/sentry/index';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
describe('SentryConfig options', () => {
|
|
|
|
const dsn = 'https://123@sentry.gitlab.test/123';
|
2017-08-17 22:00:37 +05:30
|
|
|
const currentUserId = 'currentUserId';
|
|
|
|
const gitlabUrl = 'gitlabUrl';
|
2019-07-31 22:56:46 +05:30
|
|
|
const environment = 'test';
|
2017-08-17 22:00:37 +05:30
|
|
|
const revision = 'revision';
|
|
|
|
let indexReturnValue;
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
window.gon = {
|
2019-12-26 22:10:19 +05:30
|
|
|
sentry_dsn: dsn,
|
2019-07-31 22:56:46 +05:30
|
|
|
sentry_environment: environment,
|
2017-08-17 22:00:37 +05:30
|
|
|
current_user_id: currentUserId,
|
|
|
|
gitlab_url: gitlabUrl,
|
|
|
|
revision,
|
|
|
|
};
|
|
|
|
|
|
|
|
process.env.HEAD_COMMIT_SHA = revision;
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
jest.spyOn(SentryConfig, 'init').mockImplementation();
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
indexReturnValue = index();
|
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
it('should init with .sentryDsn, .currentUserId, .whitelistUrls and environment', () => {
|
2019-12-26 22:10:19 +05:30
|
|
|
expect(SentryConfig.init).toHaveBeenCalledWith({
|
|
|
|
dsn,
|
2017-08-17 22:00:37 +05:30
|
|
|
currentUserId,
|
2019-07-31 22:56:46 +05:30
|
|
|
whitelistUrls: [gitlabUrl, 'webpack-internal://'],
|
|
|
|
environment,
|
2017-08-17 22:00:37 +05:30
|
|
|
release: revision,
|
|
|
|
tags: {
|
|
|
|
revision,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
it('should return SentryConfig', () => {
|
|
|
|
expect(indexReturnValue).toBe(SentryConfig);
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|