Commit 06736132 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Updated units

parent 13b60eb7
import RavenConfig from './raven_config'; import RavenConfig from './raven_config';
const index = RavenConfig.init.bind(RavenConfig, { const index = function index() {
RavenConfig.init({
sentryDsn: gon.sentry_dsn, sentryDsn: gon.sentry_dsn,
currentUserId: gon.current_user_id, currentUserId: gon.current_user_id,
whitelistUrls: [gon.gitlab_url], whitelistUrls: [gon.gitlab_url],
isProduction: gon.is_production, isProduction: gon.is_production,
}); });
return RavenConfig;
};
index(); index();
......
...@@ -8,8 +8,6 @@ const RavenConfig = { ...@@ -8,8 +8,6 @@ const RavenConfig = {
this.configure(); this.configure();
this.bindRavenErrors(); this.bindRavenErrors();
if (this.options.currentUserId) this.setUser(); if (this.options.currentUserId) this.setUser();
return this;
}, },
configure() { configure() {
...@@ -44,6 +42,6 @@ const RavenConfig = { ...@@ -44,6 +42,6 @@ const RavenConfig = {
}, },
}); });
}, },
} };
export default RavenConfig; export default RavenConfig;
import RavenConfig from '~/raven/raven_config'; import RavenConfig from '~/raven/raven_config';
import index from '~/raven/index'; import index from '~/raven/index';
fdescribe('RavenConfig options', () => { describe('RavenConfig options', () => {
let sentryDsn; let sentryDsn;
let currentUserId; let currentUserId;
let gitlabUrl; let gitlabUrl;
...@@ -21,13 +21,13 @@ fdescribe('RavenConfig options', () => { ...@@ -21,13 +21,13 @@ fdescribe('RavenConfig options', () => {
is_production: isProduction, is_production: isProduction,
}; };
spyOn(RavenConfig.init, 'bind'); spyOn(RavenConfig, 'init');
indexReturnValue = index(); indexReturnValue = index();
}); });
it('should init with .sentryDsn, .currentUserId, .whitelistUrls and .isProduction', () => { it('should init with .sentryDsn, .currentUserId, .whitelistUrls and .isProduction', () => {
expect(RavenConfig.init.bind).toHaveBeenCalledWith(RavenConfig, { expect(RavenConfig.init).toHaveBeenCalledWith({
sentryDsn, sentryDsn,
currentUserId, currentUserId,
whitelistUrls: [gitlabUrl], whitelistUrls: [gitlabUrl],
......
import $ from 'jquery';
import Raven from 'raven-js'; import Raven from 'raven-js';
import RavenConfig from '~/raven/raven_config'; import RavenConfig from '~/raven/raven_config';
describe('RavenConfig', () => { fdescribe('RavenConfig', () => {
describe('init', () => { describe('init', () => {
beforeEach(() => {
spyOn(RavenConfig, 'configure');
spyOn(RavenConfig, 'bindRavenErrors');
spyOn(RavenConfig, 'setUser');
});
describe('when called', () => {
let options; let options;
beforeEach(() => { beforeEach(() => {
...@@ -21,6 +15,10 @@ describe('RavenConfig', () => { ...@@ -21,6 +15,10 @@ describe('RavenConfig', () => {
isProduction: true, isProduction: true,
}; };
spyOn(RavenConfig, 'configure');
spyOn(RavenConfig, 'bindRavenErrors');
spyOn(RavenConfig, 'setUser');
RavenConfig.init(options); RavenConfig.init(options);
}); });
...@@ -39,9 +37,10 @@ describe('RavenConfig', () => { ...@@ -39,9 +37,10 @@ describe('RavenConfig', () => {
it('should call setUser', () => { it('should call setUser', () => {
expect(RavenConfig.setUser).toHaveBeenCalled(); expect(RavenConfig.setUser).toHaveBeenCalled();
}); });
});
it('should not call setUser if there is no current user ID', () => { it('should not call setUser if there is no current user ID', () => {
RavenConfig.setUser.calls.reset();
RavenConfig.init({ RavenConfig.init({
sentryDsn: '//sentryDsn', sentryDsn: '//sentryDsn',
ravenAssetUrl: '//ravenAssetUrl', ravenAssetUrl: '//ravenAssetUrl',
...@@ -55,7 +54,6 @@ describe('RavenConfig', () => { ...@@ -55,7 +54,6 @@ describe('RavenConfig', () => {
}); });
describe('configure', () => { describe('configure', () => {
describe('when called', () => {
let options; let options;
let raven; let raven;
...@@ -69,7 +67,6 @@ describe('RavenConfig', () => { ...@@ -69,7 +67,6 @@ describe('RavenConfig', () => {
raven = jasmine.createSpyObj('raven', ['install']); raven = jasmine.createSpyObj('raven', ['install']);
spyOn(Raven, 'config').and.returnValue(raven); spyOn(Raven, 'config').and.returnValue(raven);
spyOn(Raven, 'install');
RavenConfig.configure.call({ RavenConfig.configure.call({
options, options,
...@@ -84,43 +81,56 @@ describe('RavenConfig', () => { ...@@ -84,43 +81,56 @@ describe('RavenConfig', () => {
}); });
it('should call Raven.install', () => { it('should call Raven.install', () => {
expect(Raven.install).toHaveBeenCalled(); expect(raven.install).toHaveBeenCalled();
}); });
describe('if isProduction is false', () => { it('should set .environment to development if isProduction is false', () => {
beforeEach(() => {
options.isProduction = false; options.isProduction = false;
RavenConfig.configure.call({ RavenConfig.configure.call({
options, options,
}); });
});
it('should set .environment to development', () => {
expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, { expect(Raven.config).toHaveBeenCalledWith(options.sentryDsn, {
whitelistUrls: options.whitelistUrls, whitelistUrls: options.whitelistUrls,
environment: 'development', environment: 'development',
}); });
}); });
}); });
});
});
describe('setUser', () => { describe('setUser', () => {
describe('when called', () => { let ravenConfig;
beforeEach(() => {});
beforeEach(() => {
ravenConfig = { options: { currentUserId: 1 } };
spyOn(Raven, 'setUserContext');
RavenConfig.setUser.call(ravenConfig);
});
it('should call .setUserContext', function () {
expect(Raven.setUserContext).toHaveBeenCalledWith({
id: ravenConfig.options.currentUserId,
});
}); });
}); });
describe('bindRavenErrors', () => { describe('bindRavenErrors', () => {
describe('when called', () => { beforeEach(() => {
beforeEach(() => {}); RavenConfig.bindRavenErrors();
});
it('should query for document using jquery', () => {
console.log($, 'or', $.fn);
// expect($).toHaveBeenCalledWith()
});
it('should call .on', function () {
// expect($document.on).toHaveBeenCalledWith('ajaxError.raven', RavenConfig.handleRavenErrors);
}); });
}); });
describe('handleRavenErrors', () => { describe('handleRavenErrors', () => {
describe('when called', () => {
beforeEach(() => {}); beforeEach(() => {});
}); });
});
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment