Commit 27b40d16 authored by Alice Wyan's avatar Alice Wyan

Style fixes

parent 8f093474
...@@ -16,16 +16,13 @@ var Socket = require('./websocket'); ...@@ -16,16 +16,13 @@ var Socket = require('./websocket');
* @param groups - The local groups store * @param groups - The local groups store
* @param session - Provides access to read and update the session state * @param session - Provides access to read and update the session state
* @param settings - Application settings * @param settings - Application settings
*
* @return The push notification service client.
*/ */
// @ngInject // @ngInject
function Streamer($rootScope, annotationMapper, groups, session, settings) { function Streamer($rootScope, annotationMapper, groups, session, settings) {
// the randomly generated session UUID // The randomly generated session UUID
var clientId = uuid.v4(); var clientId = uuid.v4();
// the singleton socket instance, only one may // The socket instance for this Streamer instance
// be open at a time
var socket; var socket;
// Client configuration messages, to be sent each time a new connection is // Client configuration messages, to be sent each time a new connection is
...@@ -86,7 +83,7 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) { ...@@ -86,7 +83,7 @@ function Streamer($rootScope, annotationMapper, groups, session, settings) {
} }
} }
var connect = function () { var connect = function () {
// If we have no URL configured, don't do anything. // If we have no URL configured, don't do anything.
var url = settings.websocketUrl; var url = settings.websocketUrl;
if (!url) { if (!url) {
......
...@@ -83,13 +83,11 @@ describe('streamer', function () { ...@@ -83,13 +83,11 @@ describe('streamer', function () {
it('should not create a websocket connection if websocketUrl is not provided', function () { it('should not create a websocket connection if websocketUrl is not provided', function () {
fakeSettings = {}; fakeSettings = {};
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
assert.isNull(fakeWebSocket); assert.isNull(fakeWebSocket);
}); });
it('should send a client ID', function () { it('should send a client ID', function () {
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
assert.equal(fakeWebSocket.messages.length, 1); assert.equal(fakeWebSocket.messages.length, 1);
assert.equal(fakeWebSocket.messages[0].messageType, 'client_id'); assert.equal(fakeWebSocket.messages[0].messageType, 'client_id');
assert.equal(fakeWebSocket.messages[0].value, activeStreamer.clientId); assert.equal(fakeWebSocket.messages[0].value, activeStreamer.clientId);
...@@ -97,7 +95,6 @@ describe('streamer', function () { ...@@ -97,7 +95,6 @@ describe('streamer', function () {
it('should close any existing socket', function () { it('should close any existing socket', function () {
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
var oldWebSocket = fakeWebSocket; var oldWebSocket = fakeWebSocket;
activeStreamer.connect(); activeStreamer.connect();
assert.ok(oldWebSocket.didClose); assert.ok(oldWebSocket.didClose);
...@@ -107,7 +104,6 @@ describe('streamer', function () { ...@@ -107,7 +104,6 @@ describe('streamer', function () {
describe('annotation notifications', function () { describe('annotation notifications', function () {
it('should load new annotations', function () { it('should load new annotations', function () {
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
fakeWebSocket.notify({ fakeWebSocket.notify({
type: 'annotation-notification', type: 'annotation-notification',
options: { options: {
...@@ -122,7 +118,6 @@ describe('streamer', function () { ...@@ -122,7 +118,6 @@ describe('streamer', function () {
it('should unload deleted annotations', function () { it('should unload deleted annotations', function () {
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
fakeWebSocket.notify({ fakeWebSocket.notify({
type: 'annotation-notification', type: 'annotation-notification',
options: { options: {
...@@ -139,7 +134,6 @@ describe('streamer', function () { ...@@ -139,7 +134,6 @@ describe('streamer', function () {
describe('session change notifications', function () { describe('session change notifications', function () {
it('updates the session when a notification is received', function () { it('updates the session when a notification is received', function () {
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
var model = { var model = {
groups: [{ groups: [{
id: 'new-group' id: 'new-group'
...@@ -156,7 +150,6 @@ describe('streamer', function () { ...@@ -156,7 +150,6 @@ describe('streamer', function () {
describe('reconnections', function () { describe('reconnections', function () {
it('resends configuration messages when a reconnection occurs', function () { it('resends configuration messages when a reconnection occurs', function () {
createDefaultStreamer(); createDefaultStreamer();
activeStreamer.connect();
fakeWebSocket.messages = []; fakeWebSocket.messages = [];
fakeWebSocket.emit('open'); fakeWebSocket.emit('open');
assert.equal(fakeWebSocket.messages.length, 1); assert.equal(fakeWebSocket.messages.length, 1);
......
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