Rename `options` to `config` in `src/annotator/`

There are two reasons for renaming the `options` object to `config`:

**First**, it's more consistent. The file that creates this object is
called `config.js`, and the function that creates the object is called
`configFrom()`, and yet the object ends up getting called `options` (but
you have to look in another file, `main.js`, to find this out).

`config` is also used elsewhere as the name for the main configuration
object, for example in Pyramid/h, in the client docs ("Configuring the
Client", "configuration settings") and public API
(`class="js-hypothesis-config"` scripts and `window.hypothesisConfig()`
functions), etc.

These "options" that the `src/annotator/` code reads from the host page
also end up getting renamed to `hostPageConfig` when they get passed
over in to the `src/sidebar/` code.

**Second**, it's more unique. There are a number of other objects in the
`src/annotator/` code that are called options, sometimes the main
options object and another local options object are even used in the
same function. There's no other objects called config.
parent ec6c8cc5
...@@ -11,14 +11,14 @@ var docs = 'https://h.readthedocs.io/en/latest/embedding.html'; ...@@ -11,14 +11,14 @@ var docs = 'https://h.readthedocs.io/en/latest/embedding.html';
* @param {Window} window_ - The Window object to read config from. * @param {Window} window_ - The Window object to read config from.
*/ */
function configFrom(window_) { function configFrom(window_) {
var options = { var config = {
app: window_. app: window_.
document.querySelector('link[type="application/annotator+html"]').href, document.querySelector('link[type="application/annotator+html"]').href,
}; };
// Parse config from `<script class="js-hypothesis-config">` tags // Parse config from `<script class="js-hypothesis-config">` tags
try { try {
Object.assign(options, settings(window_.document)); Object.assign(config, settings(window_.document));
} catch (err) { } catch (err) {
console.warn('Could not parse settings from js-hypothesis-config tags', console.warn('Could not parse settings from js-hypothesis-config tags',
err); err);
...@@ -27,16 +27,16 @@ function configFrom(window_) { ...@@ -27,16 +27,16 @@ function configFrom(window_) {
// Parse config from `window.hypothesisConfig` function // Parse config from `window.hypothesisConfig` function
if (window_.hasOwnProperty('hypothesisConfig')) { if (window_.hasOwnProperty('hypothesisConfig')) {
if (typeof window_.hypothesisConfig === 'function') { if (typeof window_.hypothesisConfig === 'function') {
Object.assign(options, window_.hypothesisConfig()); Object.assign(config, window_.hypothesisConfig());
} else { } else {
throw new TypeError('hypothesisConfig must be a function, see: ' + docs); throw new TypeError('hypothesisConfig must be a function, see: ' + docs);
} }
} }
// Convert legacy keys/values in options to corresponding current // Convert legacy keys/values in config to corresponding current
// configuration. // configuration.
if (typeof options.showHighlights === 'boolean') { if (typeof config.showHighlights === 'boolean') {
options.showHighlights = options.showHighlights ? 'always' : 'never'; config.showHighlights = config.showHighlights ? 'always' : 'never';
} }
// Extract the default query from the URL. // Extract the default query from the URL.
...@@ -49,9 +49,9 @@ function configFrom(window_) { ...@@ -49,9 +49,9 @@ function configFrom(window_) {
// we try to retrieve it from the URL here. // we try to retrieve it from the URL here.
var directLinkedID = annotationQuery.extractAnnotationQuery(window_.location.href); var directLinkedID = annotationQuery.extractAnnotationQuery(window_.location.href);
if (directLinkedID) { if (directLinkedID) {
Object.assign(options, directLinkedID); Object.assign(config, directLinkedID);
} }
return options; return config;
} }
module.exports = configFrom; module.exports = configFrom;
...@@ -30,7 +30,7 @@ module.exports = class Delegator ...@@ -30,7 +30,7 @@ module.exports = class Delegator
# hash and extends the @options object. # hash and extends the @options object.
# #
# element - The DOM element that this instance represents. # element - The DOM element that this instance represents.
# options - An Object literal of options. # config - An Object literal of config settings.
# #
# Examples # Examples
# #
...@@ -40,8 +40,8 @@ module.exports = class Delegator ...@@ -40,8 +40,8 @@ module.exports = class Delegator
# }) # })
# #
# Returns a new instance of Delegator. # Returns a new instance of Delegator.
constructor: (element, options) -> constructor: (element, config) ->
@options = $.extend(true, {}, @options, options) @options = $.extend(true, {}, @options, config)
@element = $(element) @element = $(element)
# Delegator creates closures for each event it binds. This is a private # Delegator creates closures for each event it binds. This is a private
......
...@@ -55,7 +55,7 @@ module.exports = class Guest extends Delegator ...@@ -55,7 +55,7 @@ module.exports = class Guest extends Delegator
html: html:
adder: '<hypothesis-adder></hypothesis-adder>' adder: '<hypothesis-adder></hypothesis-adder>'
constructor: (element, options) -> constructor: (element, config) ->
super super
this.adder = $(this.html.adder).appendTo(@element).hide() this.adder = $(this.html.adder).appendTo(@element).hide()
......
...@@ -3,14 +3,14 @@ $ = require('jquery') ...@@ -3,14 +3,14 @@ $ = require('jquery')
Guest = require('./guest') Guest = require('./guest')
module.exports = class Host extends Guest module.exports = class Host extends Guest
constructor: (element, options) -> constructor: (element, config) ->
# Some options' values are not JSON-stringifiable (e.g. JavaScript # Some config settings are not JSON-stringifiable (e.g. JavaScript
# functions) and will be omitted when the options are JSON-stringified. # functions) and will be omitted when the config is JSON-stringified.
# Add a JSON-stringifiable option for each of these so that the sidebar can # Add a JSON-stringifiable option for each of these so that the sidebar can
# at least know whether the callback functions were provided or not. # at least know whether the callback functions were provided or not.
if options.services?[0] if config.services?[0]
service = options.services[0] service = config.services[0]
if service.onLoginRequest if service.onLoginRequest
service.onLoginRequestProvided = true service.onLoginRequestProvided = true
if service.onLogoutRequest if service.onLogoutRequest
...@@ -22,14 +22,15 @@ module.exports = class Host extends Guest ...@@ -22,14 +22,15 @@ module.exports = class Host extends Guest
if service.onHelpRequest if service.onHelpRequest
service.onHelpRequestProvided = true service.onHelpRequestProvided = true
# Make a copy of all options except `options.app`, the app base URL, and `options.pluginClasses` # Make a copy of all config settings except `config.app`, the app base URL,
# and `config.pluginClasses`
configParam = 'config=' + encodeURIComponent( configParam = 'config=' + encodeURIComponent(
JSON.stringify(Object.assign({}, options, {app:undefined, pluginClasses: undefined })) JSON.stringify(Object.assign({}, config, {app:undefined, pluginClasses: undefined }))
) )
if options.app and '?' in options.app if config.app and '?' in config.app
options.app += '&' + configParam config.app += '&' + configParam
else else
options.app += '?' + configParam config.app += '?' + configParam
# Create the iframe # Create the iframe
app = $('<iframe></iframe>') app = $('<iframe></iframe>')
...@@ -37,7 +38,7 @@ module.exports = class Host extends Guest ...@@ -37,7 +38,7 @@ module.exports = class Host extends Guest
# enable media in annotations to be shown fullscreen # enable media in annotations to be shown fullscreen
.attr('allowfullscreen', '') .attr('allowfullscreen', '')
.attr('seamless', '') .attr('seamless', '')
.attr('src', options.app) .attr('src', config.app)
.addClass('h-sidebar-iframe') .addClass('h-sidebar-iframe')
@frame = $('<div></div>') @frame = $('<div></div>')
...@@ -51,10 +52,10 @@ module.exports = class Host extends Guest ...@@ -51,10 +52,10 @@ module.exports = class Host extends Guest
this.on 'panelReady', => this.on 'panelReady', =>
# Initialize tool state. # Initialize tool state.
if options.showHighlights == undefined if config.showHighlights == undefined
# Highlights are on by default. # Highlights are on by default.
options.showHighlights = 'always' config.showHighlights = 'always'
this.setVisibleHighlights(options.showHighlights == 'always') this.setVisibleHighlights(config.showHighlights == 'always')
# Show the UI # Show the UI
@frame.css('display', '') @frame.css('display', '')
......
...@@ -38,20 +38,20 @@ var pluginClasses = { ...@@ -38,20 +38,20 @@ var pluginClasses = {
var appLinkEl = var appLinkEl =
document.querySelector('link[type="application/annotator+html"]'); document.querySelector('link[type="application/annotator+html"]');
var options = configFrom(window); var config = configFrom(window);
$.noConflict(true)(function() { $.noConflict(true)(function() {
var Klass = window.PDFViewerApplication ? var Klass = window.PDFViewerApplication ?
PdfSidebar : PdfSidebar :
Sidebar; Sidebar;
if (options.hasOwnProperty('constructor')) { if (config.hasOwnProperty('constructor')) {
Klass = options.constructor; Klass = config.constructor;
delete options.constructor; delete config.constructor;
} }
options.pluginClasses = pluginClasses; config.pluginClasses = pluginClasses;
window.annotator = new Klass(document.body, options); window.annotator = new Klass(document.body, config);
appLinkEl.addEventListener('destroy', function () { appLinkEl.addEventListener('destroy', function () {
appLinkEl.parentElement.removeChild(appLinkEl); appLinkEl.parentElement.removeChild(appLinkEl);
window.annotator.destroy(); window.annotator.destroy();
......
...@@ -23,11 +23,11 @@ module.exports = class Sidebar extends Host ...@@ -23,11 +23,11 @@ module.exports = class Sidebar extends Host
renderFrame: null renderFrame: null
gestureState: null gestureState: null
constructor: (element, options) -> constructor: (element, config) ->
super super
this.hide() this.hide()
if options.openSidebar || options.annotations || options.query if config.openSidebar || config.annotations || config.query
this.on 'panelReady', => this.show() this.on 'panelReady', => this.show()
if @plugins.BucketBar? if @plugins.BucketBar?
...@@ -37,7 +37,7 @@ module.exports = class Sidebar extends Host ...@@ -37,7 +37,7 @@ module.exports = class Sidebar extends Host
this._setupGestures() this._setupGestures()
# The partner-provided callback functions. # The partner-provided callback functions.
serviceConfig = options.services?[0] serviceConfig = config.services?[0]
if serviceConfig if serviceConfig
@onLoginRequest = serviceConfig.onLoginRequest @onLoginRequest = serviceConfig.onLoginRequest
@onLogoutRequest = serviceConfig.onLogoutRequest @onLogoutRequest = serviceConfig.onLogoutRequest
......
...@@ -52,7 +52,7 @@ describe('annotator.config', function() { ...@@ -52,7 +52,7 @@ describe('annotator.config', function() {
document.head.removeChild(link); document.head.removeChild(link);
}); });
it("returns the <link>'s href as options.app", function() { it("returns the <link>'s href as config.app", function() {
assert.equal(configFrom(window).app, link.href); assert.equal(configFrom(window).app, link.href);
}); });
}); });
...@@ -76,14 +76,14 @@ describe('annotator.config', function() { ...@@ -76,14 +76,14 @@ describe('annotator.config', function() {
}); });
context('when settings() returns a non-empty object', function() { context('when settings() returns a non-empty object', function() {
it('reads the setting into the returned options', function() { it('reads the setting into the returned config', function() {
// configFrom() just blindly adds any key: value settings that settings() // configFrom() just blindly adds any key: value settings that settings()
// returns into the returns options object. // returns into the returned config object.
fakeSettings.returns({foo: 'bar'}); fakeSettings.returns({foo: 'bar'});
var options = configFrom(fakeWindow()); var config = configFrom(fakeWindow());
assert.equal(options.foo, 'bar'); assert.equal(config.foo, 'bar');
}); });
}); });
...@@ -104,13 +104,13 @@ describe('annotator.config', function() { ...@@ -104,13 +104,13 @@ describe('annotator.config', function() {
}); });
context("when there's a window.hypothesisConfig() function", function() { context("when there's a window.hypothesisConfig() function", function() {
it('reads arbitrary settings from hypothesisConfig() into options', function() { it('reads arbitrary settings from hypothesisConfig() into config', function() {
var window_ = fakeWindow(); var window_ = fakeWindow();
window_.hypothesisConfig = sinon.stub().returns({foo: 'bar'}); window_.hypothesisConfig = sinon.stub().returns({foo: 'bar'});
var options = configFrom(window_); var config = configFrom(window_);
assert.equal(options.foo, 'bar'); assert.equal(config.foo, 'bar');
}); });
specify('hypothesisConfig() settings override js-hypothesis-config ones', function() { specify('hypothesisConfig() settings override js-hypothesis-config ones', function() {
...@@ -119,20 +119,20 @@ describe('annotator.config', function() { ...@@ -119,20 +119,20 @@ describe('annotator.config', function() {
foo: 'fooFromHypothesisConfigFunc'}); foo: 'fooFromHypothesisConfigFunc'});
fakeSettings.returns({foo: 'fooFromJSHypothesisConfigObj'}); fakeSettings.returns({foo: 'fooFromJSHypothesisConfigObj'});
var options = configFrom(window_); var config = configFrom(window_);
assert.equal(options.foo, 'fooFromHypothesisConfigFunc'); assert.equal(config.foo, 'fooFromHypothesisConfigFunc');
}); });
context('if hypothesisConfig() returns a non-object value', function() { context('if hypothesisConfig() returns a non-object value', function() {
it("doesn't add anything into the options", function() { it("doesn't add anything into the config", function() {
var window_ = fakeWindow(); var window_ = fakeWindow();
window_.hypothesisConfig = sinon.stub().returns(42); window_.hypothesisConfig = sinon.stub().returns(42);
var options = configFrom(window_); var config = configFrom(window_);
delete options.app; // We don't care about options.app for this test. delete config.app; // We don't care about config.app for this test.
assert.deepEqual({}, options); assert.deepEqual({}, config);
}); });
}); });
}); });
...@@ -162,7 +162,7 @@ describe('annotator.config', function() { ...@@ -162,7 +162,7 @@ describe('annotator.config', function() {
out: 'never', out: 'never',
}, },
// It adds any arbitrary string value for showHighlights to the // It adds any arbitrary string value for showHighlights to the
// returned options, unmodified. // returned config, unmodified.
{ {
name: 'passes arbitrary strings through unmodified', name: 'passes arbitrary strings through unmodified',
in: 'foo', in: 'foo',
...@@ -172,9 +172,9 @@ describe('annotator.config', function() { ...@@ -172,9 +172,9 @@ describe('annotator.config', function() {
it(test.name, function() { it(test.name, function() {
fakeSettings.returns({showHighlights: test.in}); fakeSettings.returns({showHighlights: test.in});
var options = configFrom(fakeWindow()); var config = configFrom(fakeWindow());
assert.equal(options.showHighlights, test.out); assert.equal(config.showHighlights, test.out);
}); });
}); });
}); });
...@@ -194,7 +194,7 @@ describe('annotator.config', function() { ...@@ -194,7 +194,7 @@ describe('annotator.config', function() {
}); });
}); });
it('blindly adds the properties of the object to the options', function() { it('blindly adds the properties of the object to the config', function() {
assert.equal(configFrom(fakeWindow()).foo, 'bar'); assert.equal(configFrom(fakeWindow()).foo, 'bar');
}); });
......
...@@ -50,12 +50,12 @@ describe 'Guest', -> ...@@ -50,12 +50,12 @@ describe 'Guest', ->
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
CrossFrame = null CrossFrame = null
fakeCrossFrame = null fakeCrossFrame = null
guestOptions = null guestConfig = null
createGuest = (options={}) -> createGuest = (config={}) ->
options = Object.assign({}, guestOptions, options) config = Object.assign({}, guestConfig, config)
element = document.createElement('div') element = document.createElement('div')
return new Guest(element, options) return new Guest(element, config)
beforeEach -> beforeEach ->
FakeAdder::instance = null FakeAdder::instance = null
...@@ -64,7 +64,7 @@ describe 'Guest', -> ...@@ -64,7 +64,7 @@ describe 'Guest', ->
selectionFocusRect: sinon.stub() selectionFocusRect: sinon.stub()
} }
selections = null selections = null
guestOptions = {pluginClasses: {}} guestConfig = {pluginClasses: {}}
Guest = proxyquire('../guest', { Guest = proxyquire('../guest', {
'./adder': {Adder: FakeAdder}, './adder': {Adder: FakeAdder},
...@@ -89,7 +89,7 @@ describe 'Guest', -> ...@@ -89,7 +89,7 @@ describe 'Guest', ->
} }
CrossFrame = sandbox.stub().returns(fakeCrossFrame) CrossFrame = sandbox.stub().returns(fakeCrossFrame)
guestOptions.pluginClasses['CrossFrame'] = CrossFrame guestConfig.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
...@@ -100,7 +100,7 @@ describe 'Guest', -> ...@@ -100,7 +100,7 @@ describe 'Guest', ->
beforeEach -> beforeEach ->
FakePlugin::instance = null FakePlugin::instance = null
guestOptions.pluginClasses['FakePlugin'] = FakePlugin guestConfig.pluginClasses['FakePlugin'] = FakePlugin
guest = createGuest(FakePlugin: {}) guest = createGuest(FakePlugin: {})
fakePlugin = FakePlugin::instance fakePlugin = FakePlugin::instance
......
...@@ -5,13 +5,13 @@ describe 'Host', -> ...@@ -5,13 +5,13 @@ describe 'Host', ->
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
CrossFrame = null CrossFrame = null
fakeCrossFrame = null fakeCrossFrame = null
hostOptions = {pluginClasses: {}} hostConfig = {pluginClasses: {}}
createHost = (options={}, element=null) -> createHost = (config={}, element=null) ->
options = Object.assign({app: '/base/annotator/test/empty.html'}, hostOptions, options) config = Object.assign({app: '/base/annotator/test/empty.html'}, hostConfig, config)
if !element if !element
element = document.createElement('div') element = document.createElement('div')
return new Host(element, options) return new Host(element, config)
beforeEach -> beforeEach ->
# Disable any Host logging. # Disable any Host logging.
...@@ -24,7 +24,7 @@ describe 'Host', -> ...@@ -24,7 +24,7 @@ describe 'Host', ->
CrossFrame = sandbox.stub() CrossFrame = sandbox.stub()
CrossFrame.returns(fakeCrossFrame) CrossFrame.returns(fakeCrossFrame)
hostOptions.pluginClasses['CrossFrame'] = CrossFrame hostConfig.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
...@@ -67,7 +67,7 @@ describe 'Host', -> ...@@ -67,7 +67,7 @@ describe 'Host', ->
}]) }])
assert.notCalled(frame.contentWindow.focus) assert.notCalled(frame.contentWindow.focus)
describe 'options', -> describe 'config', ->
it 'disables highlighting if showHighlights: false is given', (done) -> it 'disables highlighting if showHighlights: false is given', (done) ->
host = createHost(showHighlights: false) host = createHost(showHighlights: false)
host.on 'panelReady', -> host.on 'panelReady', ->
...@@ -82,7 +82,7 @@ describe 'Host', -> ...@@ -82,7 +82,7 @@ describe 'Host', ->
done() done()
host.publish('panelReady') host.publish('panelReady')
it 'passes options to the sidebar iframe', -> it 'passes config to the sidebar iframe', ->
appURL = new URL('/base/annotator/test/empty.html', window.location.href) appURL = new URL('/base/annotator/test/empty.html', window.location.href)
host = createHost({annotations: '1234'}) host = createHost({annotations: '1234'})
configStr = encodeURIComponent(JSON.stringify({annotations: '1234'})) configStr = encodeURIComponent(JSON.stringify({annotations: '1234'}))
......
...@@ -46,18 +46,18 @@ function FakeCrossFrame() { ...@@ -46,18 +46,18 @@ function FakeCrossFrame() {
describe('anchoring', function () { describe('anchoring', function () {
var guest; var guest;
var guestOptions; var guestConfig;
var container; var container;
before(function () { before(function () {
guestOptions = {pluginClasses: {CrossFrame: FakeCrossFrame}}; guestConfig = {pluginClasses: {CrossFrame: FakeCrossFrame}};
}); });
beforeEach(function () { beforeEach(function () {
container = document.createElement('div'); container = document.createElement('div');
container.innerHTML = require('./test-page.html'); container.innerHTML = require('./test-page.html');
document.body.appendChild(container); document.body.appendChild(container);
guest = new Guest(container, guestOptions); guest = new Guest(container, guestConfig);
}); });
afterEach(function () { afterEach(function () {
......
...@@ -7,12 +7,12 @@ describe 'Sidebar', -> ...@@ -7,12 +7,12 @@ describe 'Sidebar', ->
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
CrossFrame = null CrossFrame = null
fakeCrossFrame = null fakeCrossFrame = null
sidebarOptions = {pluginClasses: {}} sidebarConfig = {pluginClasses: {}}
createSidebar = (options={}) -> createSidebar = (config={}) ->
options = Object.assign({}, sidebarOptions, options) config = Object.assign({}, sidebarConfig, config)
element = document.createElement('div') element = document.createElement('div')
return new Sidebar(element, options) return new Sidebar(element, config)
beforeEach -> beforeEach ->
fakeCrossFrame = {} fakeCrossFrame = {}
...@@ -23,7 +23,7 @@ describe 'Sidebar', -> ...@@ -23,7 +23,7 @@ describe 'Sidebar', ->
CrossFrame = sandbox.stub() CrossFrame = sandbox.stub()
CrossFrame.returns(fakeCrossFrame) CrossFrame.returns(fakeCrossFrame)
sidebarOptions.pluginClasses['CrossFrame'] = CrossFrame sidebarConfig.pluginClasses['CrossFrame'] = CrossFrame
afterEach -> afterEach ->
sandbox.restore() sandbox.restore()
...@@ -49,21 +49,21 @@ describe 'Sidebar', -> ...@@ -49,21 +49,21 @@ describe 'Sidebar', ->
describe 'on LOGIN_REQUESTED event', -> describe 'on LOGIN_REQUESTED event', ->
it 'calls the onLoginRequest callback function if one was provided', -> it 'calls the onLoginRequest callback function if one was provided', ->
onLoginRequest = sandbox.stub() onLoginRequest = sandbox.stub()
sidebar = createSidebar(options={services: [{onLoginRequest: onLoginRequest}]}) sidebar = createSidebar(config={services: [{onLoginRequest: onLoginRequest}]})
emitEvent(events.LOGIN_REQUESTED) emitEvent(events.LOGIN_REQUESTED)
assert.called(onLoginRequest) assert.called(onLoginRequest)
it 'only calls the onLoginRequest callback of the first service', -> it 'only calls the onLoginRequest callback of the first service', ->
# Even though options.services is an array it only calls the onLoginRequest # Even though config.services is an array it only calls the onLoginRequest
# callback function of the first service. The onLoginRequests of any other # callback function of the first service. The onLoginRequests of any other
# services are ignored. # services are ignored.
firstOnLogin = sandbox.stub() firstOnLogin = sandbox.stub()
secondOnLogin = sandbox.stub() secondOnLogin = sandbox.stub()
thirdOnLogin = sandbox.stub() thirdOnLogin = sandbox.stub()
sidebar = createSidebar( sidebar = createSidebar(
options={ config={
services: [ services: [
{onLoginRequest: firstOnLogin}, {onLoginRequest: firstOnLogin},
{onLoginRequest: secondOnLogin}, {onLoginRequest: secondOnLogin},
...@@ -84,7 +84,7 @@ describe 'Sidebar', -> ...@@ -84,7 +84,7 @@ describe 'Sidebar', ->
secondOnLogin = sandbox.stub() secondOnLogin = sandbox.stub()
thirdOnLogin = sandbox.stub() thirdOnLogin = sandbox.stub()
sidebar = createSidebar( sidebar = createSidebar(
options={ config={
services: [ services: [
{}, {},
{onLoginRequest: secondOnLogin}, {onLoginRequest: secondOnLogin},
...@@ -99,21 +99,21 @@ describe 'Sidebar', -> ...@@ -99,21 +99,21 @@ describe 'Sidebar', ->
assert.notCalled(thirdOnLogin) assert.notCalled(thirdOnLogin)
it 'does not crash if there is no services', -> it 'does not crash if there is no services', ->
sidebar = createSidebar(options={}) # No options.services sidebar = createSidebar(config={}) # No config.services
emitEvent(events.LOGIN_REQUESTED) emitEvent(events.LOGIN_REQUESTED)
it 'does not crash if services is an empty array', -> it 'does not crash if services is an empty array', ->
sidebar = createSidebar(options={services: []}) sidebar = createSidebar(config={services: []})
emitEvent(events.LOGIN_REQUESTED) emitEvent(events.LOGIN_REQUESTED)
it 'does not crash if the first service has no onLoginRequest', -> it 'does not crash if the first service has no onLoginRequest', ->
sidebar = createSidebar(options={services: [{}]}) sidebar = createSidebar(config={services: [{}]})
emitEvent(events.LOGIN_REQUESTED) emitEvent(events.LOGIN_REQUESTED)
describe 'on LOGOUT_REQUESTED event', -> describe 'on LOGOUT_REQUESTED event', ->
it 'calls the onLogoutRequest callback function', -> it 'calls the onLogoutRequest callback function', ->
onLogoutRequest = sandbox.stub() onLogoutRequest = sandbox.stub()
sidebar = createSidebar(options={services: [{onLogoutRequest: onLogoutRequest}]}) sidebar = createSidebar(config={services: [{onLogoutRequest: onLogoutRequest}]})
emitEvent(events.LOGOUT_REQUESTED) emitEvent(events.LOGOUT_REQUESTED)
...@@ -122,7 +122,7 @@ describe 'Sidebar', -> ...@@ -122,7 +122,7 @@ describe 'Sidebar', ->
describe 'on SIGNUP_REQUESTED event', -> describe 'on SIGNUP_REQUESTED event', ->
it 'calls the onSignupRequest callback function', -> it 'calls the onSignupRequest callback function', ->
onSignupRequest = sandbox.stub() onSignupRequest = sandbox.stub()
sidebar = createSidebar(options={services: [{onSignupRequest: onSignupRequest}]}) sidebar = createSidebar(config={services: [{onSignupRequest: onSignupRequest}]})
emitEvent(events.SIGNUP_REQUESTED) emitEvent(events.SIGNUP_REQUESTED)
...@@ -131,7 +131,7 @@ describe 'Sidebar', -> ...@@ -131,7 +131,7 @@ describe 'Sidebar', ->
describe 'on PROFILE_REQUESTED event', -> describe 'on PROFILE_REQUESTED event', ->
it 'calls the onProfileRequest callback function', -> it 'calls the onProfileRequest callback function', ->
onProfileRequest = sandbox.stub() onProfileRequest = sandbox.stub()
sidebar = createSidebar(options={services: [{onProfileRequest: onProfileRequest}]}) sidebar = createSidebar(config={services: [{onProfileRequest: onProfileRequest}]})
emitEvent(events.PROFILE_REQUESTED) emitEvent(events.PROFILE_REQUESTED)
...@@ -140,7 +140,7 @@ describe 'Sidebar', -> ...@@ -140,7 +140,7 @@ describe 'Sidebar', ->
describe 'on HELP_REQUESTED event', -> describe 'on HELP_REQUESTED event', ->
it 'calls the onHelpRequest callback function', -> it 'calls the onHelpRequest callback function', ->
onHelpRequest = sandbox.stub() onHelpRequest = sandbox.stub()
sidebar = createSidebar(options={services: [{onHelpRequest: onHelpRequest}]}) sidebar = createSidebar(config={services: [{onHelpRequest: onHelpRequest}]})
emitEvent(events.HELP_REQUESTED) emitEvent(events.HELP_REQUESTED)
......
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