Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-04 16:58:45 +0300
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-13 19:18:15 +0300
commitcfd3d0fd377c3438c6ce8bc2f20b11f86b43a785 (patch)
treeaae1be8d8624e9bca4524dea1fdbdea26acb838f /spec/javascripts/raven/raven_config_spec.js
parentccca73d779ae0e22a86c9586fd52b15a8600b9f3 (diff)
[ci skip] Remove loadscript class in favour of backend conditional
Diffstat (limited to 'spec/javascripts/raven/raven_config_spec.js')
-rw-r--r--spec/javascripts/raven/raven_config_spec.js137
1 files changed, 137 insertions, 0 deletions
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(() => {});
+ });
+ });
+});