summaryrefslogtreecommitdiff
path: root/spec/frontend/sentry/index_spec.js
blob: 13b9b9e909c2c2fa5a7e35bf80a7c745b797238c (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import index from '~/sentry/index';
import SentryConfig from '~/sentry/sentry_config';

describe('SentryConfig options', () => {
  const dsn = 'https://123@sentry.gitlab.test/123';
  const currentUserId = 'currentUserId';
  const gitlabUrl = 'gitlabUrl';
  const environment = 'test';
  const revision = 'revision';
  let indexReturnValue;

  beforeEach(() => {
    window.gon = {
      sentry_dsn: dsn,
      sentry_environment: environment,
      current_user_id: currentUserId,
      gitlab_url: gitlabUrl,
      revision,
    };

    process.env.HEAD_COMMIT_SHA = revision;

    jest.spyOn(SentryConfig, 'init').mockImplementation();

    indexReturnValue = index();
  });

  it('should init with .sentryDsn, .currentUserId, .whitelistUrls and environment', () => {
    expect(SentryConfig.init).toHaveBeenCalledWith({
      dsn,
      currentUserId,
      whitelistUrls: [gitlabUrl, 'webpack-internal://'],
      environment,
      release: revision,
      tags: {
        revision,
      },
    });
  });

  it('should return SentryConfig', () => {
    expect(indexReturnValue).toBe(SentryConfig);
  });
});