summaryrefslogtreecommitdiff
path: root/spec/javascripts/raven/index_spec.js
blob: b5662cd0331c7a37d93643931435adc8f1dd0c34 (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
import RavenConfig from '~/raven/raven_config';
import index from '~/raven/index';

describe('RavenConfig options', () => {
  let sentryDsn;
  let currentUserId;
  let gitlabUrl;
  let isProduction;
  let indexReturnValue;

  beforeEach(() => {
    sentryDsn = 'sentryDsn';
    currentUserId = 'currentUserId';
    gitlabUrl = 'gitlabUrl';
    isProduction = 'isProduction';

    window.gon = {
      sentry_dsn: sentryDsn,
      current_user_id: currentUserId,
      gitlab_url: gitlabUrl,
    };

    process.env.NODE_ENV = isProduction;

    spyOn(RavenConfig, 'init');

    indexReturnValue = index();
  });

  it('should init with .sentryDsn, .currentUserId, .whitelistUrls and .isProduction', () => {
    expect(RavenConfig.init).toHaveBeenCalledWith({
      sentryDsn,
      currentUserId,
      whitelistUrls: [gitlabUrl],
      isProduction,
    });
  });

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