diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-04 14:58:45 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-13 17:18:15 +0100 |
commit | cfd3d0fd377c3438c6ce8bc2f20b11f86b43a785 (patch) | |
tree | aae1be8d8624e9bca4524dea1fdbdea26acb838f /spec/javascripts/raven | |
parent | ccca73d779ae0e22a86c9586fd52b15a8600b9f3 (diff) | |
download | gitlab-ce-cfd3d0fd377c3438c6ce8bc2f20b11f86b43a785.tar.gz |
[ci skip] Remove loadscript class in favour of backend conditional
Diffstat (limited to 'spec/javascripts/raven')
-rw-r--r-- | spec/javascripts/raven/index_spec.js | 11 | ||||
-rw-r--r-- | spec/javascripts/raven/raven_config_spec.js | 137 |
2 files changed, 148 insertions, 0 deletions
diff --git a/spec/javascripts/raven/index_spec.js b/spec/javascripts/raven/index_spec.js new file mode 100644 index 00000000000..51e84a6dbee --- /dev/null +++ b/spec/javascripts/raven/index_spec.js @@ -0,0 +1,11 @@ +import RavenConfig from '~/raven/index'; + +describe('RavenConfig options', () => { + it('should set sentryDsn'); + + it('should set currentUserId'); + + it('should set whitelistUrls'); + + it('should set isProduction'); +}); diff --git a/spec/javascripts/raven/raven_config_spec.js b/spec/javascripts/raven/raven_config_spec.js new file mode 100644 index 00000000000..2b63f56d719 --- /dev/null +++ b/spec/javascripts/raven/raven_config_spec.js @@ -0,0 +1,137 @@ +import Raven from 'raven-js'; +import RavenConfig from '~/raven/raven_config'; +import ClassSpecHelper from '../helpers/class_spec_helper'; + +fdescribe('RavenConfig', () => { + describe('init', () => { + beforeEach(() => { + spyOn(RavenConfig, 'configure'); + spyOn(RavenConfig, 'bindRavenErrors'); + spyOn(RavenConfig, 'setUser'); + }); + + ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'init'); + + describe('when called', () => { + let options; + + beforeEach(() => { + options = { + sentryDsn: '//sentryDsn', + ravenAssetUrl: '//ravenAssetUrl', + currentUserId: 1, + whitelistUrls: ['//gitlabUrl'], + isProduction: true, + }; + + RavenConfig.init(options); + }); + + it('should set the options property', () => { + expect(RavenConfig.options).toEqual(options); + }); + + it('should call the configure method', () => { + expect(RavenConfig.configure).toHaveBeenCalled(); + }); + + it('should call the error bindings method', () => { + expect(RavenConfig.bindRavenErrors).toHaveBeenCalled(); + }); + + it('should call setUser', () => { + expect(RavenConfig.setUser).toHaveBeenCalled(); + }); + }); + + it('should not call setUser if there is no current user ID', () => { + RavenConfig.init({ + sentryDsn: '//sentryDsn', + ravenAssetUrl: '//ravenAssetUrl', + currentUserId: undefined, + whitelistUrls: ['//gitlabUrl'], + isProduction: true, + }); + + expect(RavenConfig.setUser).not.toHaveBeenCalled(); + }); + }); + + describe('configure', () => { + ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'configure'); + + describe('when called', () => { + let options; + let raven; + + beforeEach(() => { + options = { + sentryDsn: '//sentryDsn', + whitelistUrls: ['//gitlabUrl'], + isProduction: true, + }; + + raven = jasmine.createSpyObj('raven', ['install']); + + spyOn(Raven, 'config').and.returnValue(raven); + spyOn(Raven, 'install'); + + RavenConfig.configure.call({ + options, + }); + }); + + it('should call Raven.config', () => { + expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, { + whitelistUrls: options.whitelistUrls, + environment: 'production', + }); + }); + + it('should call Raven.install', () => { + expect(Raven.install).toHaveBeenCalled(); + }); + + describe('if isProduction is false', () => { + beforeEach(() => { + options.isProduction = false; + + RavenConfig.configure.call({ + options, + }); + }); + + it('should set .environment to development', () => { + expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, { + whitelistUrls: options.whitelistUrls, + environment: 'development', + }); + }); + }); + }); + }); + + describe('setUser', () => { + ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'setUser'); + + describe('when called', () => { + beforeEach(() => {}); + }); + }); + + describe('bindRavenErrors', () => { + ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'bindRavenErrors'); + + describe('when called', () => { + beforeEach(() => {}); + }); + }); + + describe('handleRavenErrors', () => { + ClassSpecHelper.itShouldBeAStaticMethod(RavenConfig, 'handleRavenErrors'); + + describe('when called', () => { + beforeEach(() => {}); + }); + }); +}); |