diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..32bb882d2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +test/e2e/support/error/under-test.js \ No newline at end of file diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 8a5800eb3..940a6f8b2 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -61,7 +61,8 @@ module.exports = (grunt) -> '<%= files.server %>' '<%= files.grunt %>' '<%= files.scripts %>' - '<%= files.client %>' + '<%= files.client %>', + 'test/**/*.js' ] # CoffeeLint options diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 000000000..3c8fcd734 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,8 @@ +{ + "env": { + "mocha": true + }, + "globals": { + "expect": true + } +} diff --git a/test/client/.eslintrc b/test/client/.eslintrc new file mode 100644 index 000000000..8f99b3e1e --- /dev/null +++ b/test/client/.eslintrc @@ -0,0 +1,5 @@ +{ + "env": { + "jasmine": true + } +} \ No newline at end of file diff --git a/test/client/karma.conf.js b/test/client/karma.conf.js index c08e52a2e..de9cc1c31 100644 --- a/test/client/karma.conf.js +++ b/test/client/karma.conf.js @@ -1,4 +1,4 @@ -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path, that will be used to resolve files and exclude basePath: '../..', @@ -78,5 +78,5 @@ module.exports = function(config) { 'karma-junit-reporter', 'karma-commonjs' ] - }); -}; + }) +} diff --git a/test/client/karma.spec.js b/test/client/karma.spec.js index e866e33c3..b972de7d4 100644 --- a/test/client/karma.spec.js +++ b/test/client/karma.spec.js @@ -1,302 +1,280 @@ -var Karma = require('../../client/karma'); -var MockSocket = require('./mocks').Socket; - - -describe('Karma', function() { - var socket, k, spyStart, windowNavigator, windowLocation, spyWindowOpener; - - var setTransportTo = function(transportName) { - socket._setTransportNameTo(transportName); - socket.emit('connect'); - }; - - - beforeEach(function() { - socket = new MockSocket(); - windowNavigator = {}; - windowLocation = {search: ''}; - spyWindowOpener = jasmine.createSpy('window.open').andReturn({}); - k = new Karma(socket, {}, spyWindowOpener, windowNavigator, windowLocation); - spyStart = spyOn(k, 'start'); - }); - - - it('should start execution when all files loaded and pass config', function() { +var Karma = require('../../client/karma') +var MockSocket = require('./mocks').Socket + +describe('Karma', function () { + var socket, k, spyStart, windowNavigator, windowLocation, spyWindowOpener + + var setTransportTo = function (transportName) { + socket._setTransportNameTo(transportName) + socket.emit('connect') + } + + beforeEach(function () { + socket = new MockSocket() + windowNavigator = {} + windowLocation = {search: ''} + spyWindowOpener = jasmine.createSpy('window.open').andReturn({}) + k = new Karma(socket, {}, spyWindowOpener, windowNavigator, windowLocation) + spyStart = spyOn(k, 'start') + }) + + it('should start execution when all files loaded and pass config', function () { var config = { useIframe: true - }; - - socket.emit('execute', config); - expect(spyStart).not.toHaveBeenCalled(); + } - k.loaded(); - expect(spyStart).toHaveBeenCalledWith(config); - }); + socket.emit('execute', config) + expect(spyStart).not.toHaveBeenCalled() + k.loaded() + expect(spyStart).toHaveBeenCalledWith(config) + }) - it('should open a new window when useIFrame is false', function() { + it('should open a new window when useIFrame is false', function () { var config = { useIframe: false - }; - - socket.emit('execute', config); - expect(spyStart).not.toHaveBeenCalled(); - - k.loaded(); - expect(spyStart).toHaveBeenCalledWith(config); - expect(spyWindowOpener).toHaveBeenCalledWith('about:blank'); - }); - - - it('should not start execution if any error during loading files', function() { - k.error('syntax error', '/some/file.js', 11); - k.loaded(); + } - expect(spyStart).not.toHaveBeenCalled(); - }); + socket.emit('execute', config) + expect(spyStart).not.toHaveBeenCalled() + k.loaded() + expect(spyStart).toHaveBeenCalledWith(config) + expect(spyWindowOpener).toHaveBeenCalledWith('about:blank') + }) - it('should remove reference to start even after syntax error', function() { - var ADAPTER_START_FN = function() {}; + it('should not start execution if any error during loading files', function () { + k.error('syntax error', '/some/file.js', 11) + k.loaded() - k.start = ADAPTER_START_FN; - k.error('syntax error', '/some/file.js', 11); - k.loaded(); - expect(k.start).not.toBe(ADAPTER_START_FN); + expect(spyStart).not.toHaveBeenCalled() + }) - k.start = ADAPTER_START_FN; - k.loaded(); - expect(k.start).not.toBe(ADAPTER_START_FN); - }); + it('should remove reference to start even after syntax error', function () { + var ADAPTER_START_FN = function () {} + k.start = ADAPTER_START_FN + k.error('syntax error', '/some/file.js', 11) + k.loaded() + expect(k.start).not.toBe(ADAPTER_START_FN) - it('should not set up context if there was an error', function() { - var mockWindow = {}; + k.start = ADAPTER_START_FN + k.loaded() + expect(k.start).not.toBe(ADAPTER_START_FN) + }) - k.error('page reload'); - k.setupContext(mockWindow); + it('should not set up context if there was an error', function () { + var mockWindow = {} - expect(mockWindow.__karma__).toBeUndefined(); - expect(mockWindow.onbeforeunload).toBeUndefined(); - expect(mockWindow.onerror).toBeUndefined(); - }); + k.error('page reload') + k.setupContext(mockWindow) + expect(mockWindow.__karma__).toBeUndefined() + expect(mockWindow.onbeforeunload).toBeUndefined() + expect(mockWindow.onerror).toBeUndefined() + }) - it('should report navigator name', function() { - var spyInfo = jasmine.createSpy('onInfo').andCallFake(function(info) { - expect(info.name).toBe('Fake browser name'); - }); - - windowNavigator.userAgent = 'Fake browser name'; - windowLocation.search = ''; - socket.on('register', spyInfo); - socket.emit('connect'); - - expect(spyInfo).toHaveBeenCalled(); - }); - + it('should report navigator name', function () { + var spyInfo = jasmine.createSpy('onInfo').andCallFake(function (info) { + expect(info.name).toBe('Fake browser name') + }) - it('should report browser id', function() { - windowLocation.search = '?id=567'; - socket = new MockSocket(); - k = new Karma(socket, {}, window.open, windowNavigator, windowLocation); + windowNavigator.userAgent = 'Fake browser name' + windowLocation.search = '' + socket.on('register', spyInfo) + socket.emit('connect') - var spyInfo = jasmine.createSpy('onInfo').andCallFake(function(info) { - expect(info.id).toBe('567'); - }); + expect(spyInfo).toHaveBeenCalled() + }) - socket.on('register', spyInfo); - socket.emit('connect'); + it('should report browser id', function () { + windowLocation.search = '?id=567' + socket = new MockSocket() + k = new Karma(socket, {}, window.open, windowNavigator, windowLocation) - expect(spyInfo).toHaveBeenCalled(); - }); + var spyInfo = jasmine.createSpy('onInfo').andCallFake(function (info) { + expect(info.id).toBe('567') + }) + socket.on('register', spyInfo) + socket.emit('connect') - describe('result', function() { - var spyResult; + expect(spyInfo).toHaveBeenCalled() + }) - beforeEach(function() { - spyResult = jasmine.createSpy('onResult'); - socket.on('result', spyResult); - }); + describe('result', function () { + var spyResult + beforeEach(function () { + spyResult = jasmine.createSpy('onResult') + socket.on('result', spyResult) + }) - it('should buffer results when polling', function() { - setTransportTo('xhr-polling'); + it('should buffer results when polling', function () { + setTransportTo('xhr-polling') // emit 49 results for (var i = 1; i < 50; i++) { - k.result({id: i}); + k.result({id: i}) } - expect(spyResult).not.toHaveBeenCalled(); - - k.result('result', {id: 50}); - expect(spyResult).toHaveBeenCalled(); - expect(spyResult.argsForCall[0][0].length).toBe(50); - }); + expect(spyResult).not.toHaveBeenCalled() + k.result('result', {id: 50}) + expect(spyResult).toHaveBeenCalled() + expect(spyResult.argsForCall[0][0].length).toBe(50) + }) - it('should buffer results when polling', function() { - setTransportTo('xhr-polling'); + it('should buffer results when polling', function () { + setTransportTo('xhr-polling') // emit 40 results for (var i = 1; i <= 40; i++) { - k.result({id: i}); + k.result({id: i}) } - k.complete(); - expect(spyResult).toHaveBeenCalled(); - expect(spyResult.argsForCall[0][0].length).toBe(40); - }); - + k.complete() + expect(spyResult).toHaveBeenCalled() + expect(spyResult.argsForCall[0][0].length).toBe(40) + }) - it('should emit "start" with total specs count first', function() { - var log = []; - spyResult.andCallFake(function() { - log.push('result'); - }); + it('should emit "start" with total specs count first', function () { + var log = [] + spyResult.andCallFake(function () { + log.push('result') + }) - socket.on('start', function() { - log.push('start'); - }); + socket.on('start', function () { + log.push('start') + }) // adapter didn't call info({total: x}) - k.result(); - expect(log).toEqual(['start', 'result']); - }); - - - it('should not emit "start" if already done by the adapter', function() { - var log = []; - var spyStart = jasmine.createSpy('onStart').andCallFake(function() { - log.push('start'); - }); - spyResult.andCallFake(function() { - log.push('result'); - }); - - socket.on('start', spyStart); - - k.info({total: 321}); - k.result(); - expect(log).toEqual(['start', 'result']); - expect(spyStart).toHaveBeenCalledWith({total: 321}); - }); - }); + k.result() + expect(log).toEqual(['start', 'result']) + }) + it('should not emit "start" if already done by the adapter', function () { + var log = [] + var spyStart = jasmine.createSpy('onStart').andCallFake(function () { + log.push('start') + }) + spyResult.andCallFake(function () { + log.push('result') + }) + + socket.on('start', spyStart) + + k.info({total: 321}) + k.result() + expect(log).toEqual(['start', 'result']) + expect(spyStart).toHaveBeenCalledWith({total: 321}) + }) + }) - describe('setupContext', function() { - it('should capture alert', function() { - spyOn(k, 'log'); + describe('setupContext', function () { + it('should capture alert', function () { + spyOn(k, 'log') var mockWindow = { - alert: function() { - throw 'Alert was not patched!'; + alert: function () { + throw new Error('Alert was not patched!') } - }; + } - k.setupContext(mockWindow); - mockWindow.alert('What?'); - expect(k.log).toHaveBeenCalledWith('alert', ['What?']); + k.setupContext(mockWindow) + mockWindow.alert('What?') + expect(k.log).toHaveBeenCalledWith('alert', ['What?']) }) - }); - - - describe('store', function() { - - it('should be getter/setter', function() { - k.store('a', 10); - k.store('b', [1, 2, 3]); - - expect(k.store('a')).toBe(10); - expect(k.store('b')).toEqual([1, 2, 3]); - }); - - - it('should clone arrays to avoid memory leaks', function() { - var array = [1, 2, 3, 4, 5]; + }) - k.store('one.array', array); - expect(k.store('one.array')).toEqual(array); - expect(k.store('one.array')).not.toBe(array); - }); - }); + describe('store', function () { + it('should be getter/setter', function () { + k.store('a', 10) + k.store('b', [1, 2, 3]) + expect(k.store('a')).toBe(10) + expect(k.store('b')).toEqual([1, 2, 3]) + }) - describe('complete', function() { + it('should clone arrays to avoid memory leaks', function () { + var array = [1, 2, 3, 4, 5] - beforeEach(function() { - spyOn(window, 'setTimeout').andCallFake(function(fn) { - fn(); - }); - }); + k.store('one.array', array) + expect(k.store('one.array')).toEqual(array) + expect(k.store('one.array')).not.toBe(array) + }) + }) + describe('complete', function () { + beforeEach(function () { + spyOn(window, 'setTimeout').andCallFake(function (fn) { + fn() + }) + }) - it('should clean the result buffer before completing', function() { - var spyResult = jasmine.createSpy('onResult'); - socket.on('result', spyResult); + it('should clean the result buffer before completing', function () { + var spyResult = jasmine.createSpy('onResult') + socket.on('result', spyResult) - setTransportTo('xhr-polling'); + setTransportTo('xhr-polling') // emit 40 results for (var i = 0; i < 40; i++) { - k.result({id: i}); + k.result({id: i}) } - expect(spyResult).not.toHaveBeenCalled(); - - k.complete(); - expect(spyResult).toHaveBeenCalled(); - }); + expect(spyResult).not.toHaveBeenCalled() + k.complete() + expect(spyResult).toHaveBeenCalled() + }) - it('should navigate the client to return_url if specified', function() { - windowLocation.search = '?id=567&return_url=http://return.com'; - socket = new MockSocket(); - k = new Karma(socket, {}, window.open, windowNavigator, windowLocation); + it('should navigate the client to return_url if specified', function () { + windowLocation.search = '?id=567&return_url=http://return.com' + socket = new MockSocket() + k = new Karma(socket, {}, window.open, windowNavigator, windowLocation) - spyOn(socket, 'disconnect'); + spyOn(socket, 'disconnect') - socket.on('complete', function(data, ack) { - ack(); - }); + socket.on('complete', function (data, ack) { + ack() + }) - k.complete(); + k.complete() - waitsFor(function(){ - return windowLocation.href === 'http://return.com'; - }, '', 9000); - }); + waitsFor(function () { + return windowLocation.href === 'http://return.com' + }, '', 9000) + }) - it('should patch the console if captureConsole is true', function() { - spyOn(k, 'log'); - k.config.captureConsole = true; + it('should patch the console if captureConsole is true', function () { + spyOn(k, 'log') + k.config.captureConsole = true var mockWindow = { console: { log: function () {} } - }; + } - k.setupContext(mockWindow); - mockWindow.console.log('What?'); - expect(k.log).toHaveBeenCalledWith('log', ['What?']); - }); + k.setupContext(mockWindow) + mockWindow.console.log('What?') + expect(k.log).toHaveBeenCalledWith('log', ['What?']) + }) - it('should not patch the console if captureConsole is false', function() { - spyOn(k, 'log'); - k.config.captureConsole = false; + it('should not patch the console if captureConsole is false', function () { + spyOn(k, 'log') + k.config.captureConsole = false var mockWindow = { console: { log: function () {} } - }; - - k.setupContext(mockWindow); - mockWindow.console.log('hello'); - expect(k.log).not.toHaveBeenCalled(); - }); - }); -}); + } + + k.setupContext(mockWindow) + mockWindow.console.log('hello') + expect(k.log).not.toHaveBeenCalled() + }) + }) +}) diff --git a/test/client/mocks.js b/test/client/mocks.js index 67a746d1d..d5e95f5df 100644 --- a/test/client/mocks.js +++ b/test/client/mocks.js @@ -1,42 +1,40 @@ -var Emitter = function() { - var listeners = {}; +var Emitter = function () { + var listeners = {} - this.on = function(event, fn) { + this.on = function (event, fn) { if (!listeners[event]) { - listeners[event] = []; + listeners[event] = [] } - listeners[event].push(fn); - }; + listeners[event].push(fn) + } - this.emit = function(event) { - var eventListeners = listeners[event]; + this.emit = function (event) { + var eventListeners = listeners[event] - if (!eventListeners) return; + if (!eventListeners) return - var i = 0; + var i = 0 while (i < eventListeners.length) { - eventListeners[i].apply(null, Array.prototype.slice.call(arguments, 1)); - i++; + eventListeners[i].apply(null, Array.prototype.slice.call(arguments, 1)) + i++ } - }; -}; + } +} +var MockSocket = function () { + Emitter.call(this) -var MockSocket = function() { - Emitter.call(this); + this.socket = {transport: {name: 'websocket'}} - this.socket = {transport: {name: 'websocket'}}; - - this.disconnect = function() { - this.emit('disconnect'); - }; + this.disconnect = function () { + this.emit('disconnect') + } // MOCK API - this._setTransportNameTo = function(transportName) { - this.socket.transport.name = transportName; - }; -}; - + this._setTransportNameTo = function (transportName) { + this.socket.transport.name = transportName + } +} -exports.Socket = MockSocket; +exports.Socket = MockSocket diff --git a/test/client/stringify.spec.js b/test/client/stringify.spec.js index 140d878ac..0c02a1952 100644 --- a/test/client/stringify.spec.js +++ b/test/client/stringify.spec.js @@ -1,74 +1,68 @@ -var stringify = require('../../client/stringify'); +/* global __karma__ */ +var stringify = require('../../client/stringify') -describe('stringify', function() { - it('should serialize string', function() { - expect(stringify('aaa')).toBe("'aaa'"); - }); +describe('stringify', function () { + it('should serialize string', function () { + expect(stringify('aaa')).toBe("'aaa'") + }) + it('should serialize booleans', function () { + expect(stringify(true)).toBe('true') + expect(stringify(false)).toBe('false') + }) - it('should serialize booleans', function() { - expect(stringify(true)).toBe('true'); - expect(stringify(false)).toBe('false'); - }); + it('should serialize null and undefined', function () { + expect(stringify(null)).toBe('null') + expect(stringify()).toBe('undefined') + }) + it('should serialize functions', function () { + function abc (a, b, c) { return 'whatever' } + var def = function (d, e, f) { return 'whatever' } - it('should serialize null and undefined', function() { - expect(stringify(null)).toBe('null'); - expect(stringify()).toBe('undefined'); - }); + expect(stringify(abc)).toBe('function abc(a, b, c) { ... }') + expect(stringify(def)).toBe('function (d, e, f) { ... }') + }) - - it('should serialize functions', function() { - function abc(a, b, c) { return 'whatever'; } - var def = function(d, e, f) { return 'whatever'; }; - - expect(stringify(abc)).toBe('function abc(a, b, c) { ... }'); - expect(stringify(def)).toBe('function (d, e, f) { ... }'); - }); - - - it('should serialize arrays', function() { - expect(stringify(['a', 'b', null, true, false])).toBe("['a', 'b', null, true, false]"); - }); + it('should serialize arrays', function () { + expect(stringify(['a', 'b', null, true, false])).toBe("['a', 'b', null, true, false]") + }) it('should serialize objects', function () { - var obj; + var obj + obj = {a: 'a', b: 'b', c: null, d: true, e: false} + expect(stringify(obj)).toBe("Object{a: 'a', b: 'b', c: null, d: true, e: false}") - obj = {a: 'a', b: 'b', c: null, d: true, e: false}; - expect(stringify(obj)).toBe('Object{a: \'a\', b: \'b\', c: null, d: true, e: false}'); - - function MyObj() { - this.a = 'a'; + function MyObj () { + this.a = 'a' } - obj = new MyObj(); - expect(stringify(obj)).toBe('MyObj{a: \'a\'}'); - - obj = {constructor: null}; - expect(stringify(obj)).toBe('Object{constructor: null}'); - - obj = Object.create(null); - obj.a = 'a'; - expect(stringify(obj)).toBe('Object{a: \'a\'}'); - }); + obj = new MyObj() + expect(stringify(obj)).toBe("MyObj{a: 'a'}") + obj = {constructor: null} + expect(stringify(obj)).toBe('Object{constructor: null}') - it('should serialize html', function() { - var div = document.createElement('div'); + obj = Object.create(null) + obj.a = 'a' + expect(stringify(obj)).toBe("Object{a: 'a'}") + }) - expect(stringify(div)).toBe('
'); + it('should serialize html', function () { + var div = document.createElement('div') - div.innerHTML = 'some text'; - expect(stringify(div)).toBe('
some text
'); - }); + expect(stringify(div)).toBe('
') + div.innerHTML = 'some text' + expect(stringify(div)).toBe('
some text
') + }) - it('should serialize across iframes', function() { - var div = document.createElement('div'); - expect(__karma__.stringify(div)).toBe('
'); + it('should serialize across iframes', function () { + var div = document.createElement('div') + expect(__karma__.stringify(div)).toBe('
') - expect(__karma__.stringify([1, 2])).toBe('[1, 2]'); - }); -}); + expect(__karma__.stringify([1, 2])).toBe('[1, 2]') + }) +}) diff --git a/test/client/util.spec.js b/test/client/util.spec.js index 8c7c01d58..3b2e8822c 100644 --- a/test/client/util.spec.js +++ b/test/client/util.spec.js @@ -1,11 +1,9 @@ -var util = require('../../client/util'); +var util = require('../../client/util') +describe('util', function () { + describe('parseQueryParams', function () { + var params = util.parseQueryParams('?id=123&return_url=http://whatever.com') -describe('util', function() { - - describe('parseQueryParams', function() { - var params = util.parseQueryParams('?id=123&return_url=http://whatever.com'); - - expect(params).toEqual({id: '123', return_url: 'http://whatever.com'}); - }); -}); + expect(params).toEqual({id: '123', return_url: 'http://whatever.com'}) + }) +}) diff --git a/test/e2e/.eslintrc b/test/e2e/.eslintrc new file mode 100644 index 000000000..e5a34aec6 --- /dev/null +++ b/test/e2e/.eslintrc @@ -0,0 +1,5 @@ +{ + "env": { + "browser": true + } +} diff --git a/test/e2e/support/basic/plus.js b/test/e2e/support/basic/plus.js index c3aa2d83c..d7fd9e84e 100644 --- a/test/e2e/support/basic/plus.js +++ b/test/e2e/support/basic/plus.js @@ -1,4 +1,5 @@ +/* eslint-disable no-unused-vars */ // Some code under test -function plus(a, b) { - return a + b; +function plus (a, b) { + return a + b } diff --git a/test/e2e/support/basic/test.js b/test/e2e/support/basic/test.js index 9e34557ef..e2883be26 100644 --- a/test/e2e/support/basic/test.js +++ b/test/e2e/support/basic/test.js @@ -1,9 +1,10 @@ -describe('plus', function() { - it('should pass', function() { - expect(true).toBe(true); - }); +/* globals plus */ +describe('plus', function () { + it('should pass', function () { + expect(true).toBe(true) + }) - it('should work', function() { - expect(plus(1, 2)).toBe(3); - }); -}); + it('should work', function () { + expect(plus(1, 2)).toBe(3) + }) +}) diff --git a/test/e2e/support/error/test.js b/test/e2e/support/error/test.js index 9e34557ef..e02f9e82f 100644 --- a/test/e2e/support/error/test.js +++ b/test/e2e/support/error/test.js @@ -1,9 +1,10 @@ -describe('plus', function() { - it('should pass', function() { - expect(true).toBe(true); - }); +/* global plus */ +describe('plus', function () { + it('should pass', function () { + expect(true).toBe(true) + }) - it('should work', function() { - expect(plus(1, 2)).toBe(3); - }); -}); + it('should work', function () { + expect(plus(1, 2)).toBe(3) + }) +}) diff --git a/test/e2e/support/pass-opts/test.js b/test/e2e/support/pass-opts/test.js index e283afff4..34710a1b0 100644 --- a/test/e2e/support/pass-opts/test.js +++ b/test/e2e/support/pass-opts/test.js @@ -1,6 +1,6 @@ -describe('config', function() { - it('should be passed through to the browser', function() { - expect(window.__karma__.config).toBeDefined(); - expect(window.__karma__.config.args).toEqual(['arg1','arg2']); - }); -}); +describe('config', function () { + it('should be passed through to the browser', function () { + expect(window.__karma__.config).toBeDefined() + expect(window.__karma__.config.args).toEqual(['arg1', 'arg2']) + }) +}) diff --git a/test/e2e/support/proxy/test.js b/test/e2e/support/proxy/test.js index d80ef1b8c..c8222c4be 100644 --- a/test/e2e/support/proxy/test.js +++ b/test/e2e/support/proxy/test.js @@ -1,14 +1,14 @@ -function httpGet(url) { - var xmlHttp = new XMLHttpRequest(); +function httpGet (url) { + var xmlHttp = new XMLHttpRequest() - xmlHttp.open('GET', url, false); - xmlHttp.send(null); + xmlHttp.open('GET', url, false) + xmlHttp.send(null) - return xmlHttp.responseText; + return xmlHttp.responseText } -describe('foo', function() { - it('should should serve /foo.js', function() { - expect(httpGet('/foo.js')).toBe("'/base/proxy/foo.js source'\n"); - }); -}); +describe('foo', function () { + it('should should serve /foo.js', function () { + expect(httpGet('/foo.js')).toBe("'/base/proxy/foo.js source'\n") + }) +}) diff --git a/test/e2e/support/reconnecting/plus.js b/test/e2e/support/reconnecting/plus.js index c3aa2d83c..d7fd9e84e 100644 --- a/test/e2e/support/reconnecting/plus.js +++ b/test/e2e/support/reconnecting/plus.js @@ -1,4 +1,5 @@ +/* eslint-disable no-unused-vars */ // Some code under test -function plus(a, b) { - return a + b; +function plus (a, b) { + return a + b } diff --git a/test/e2e/support/reconnecting/test.js b/test/e2e/support/reconnecting/test.js index b58430e91..4515520c7 100644 --- a/test/e2e/support/reconnecting/test.js +++ b/test/e2e/support/reconnecting/test.js @@ -1,46 +1,46 @@ -describe('plus', function() { - - var breath = function() { - var finished = false; - setTimeout(function() { - finished = true; +/* globals waitsFor, plus */ +describe('plus', function () { + var breath = function () { + var finished = false + setTimeout(function () { + finished = true }, 0) - waitsFor(function() { - return finished; - }); - }; + waitsFor(function () { + return finished + }) + } // super hacky way to get the actual socket to manipulate it... - var socket = function() { - var location = window.parent.location; - return window.parent.io.sockets[location.protocol + '//' + location.host]; - }; - - it('should pass', function() { - expect(1).toBe(1); - }); - - it('should disconnect', function() { - expect(2).toBe(2); - socket().disconnect(); - - breath(); - }); - - it('should work', function() { - expect(plus(1, 2)).toBe(3); - }); - - it('should re-connect', function() { - expect(4).toBe(4); - socket().reconnect(); - // window.parent.socket.socket.connect(); - - breath(); - }); - - it('should work', function() { - expect(plus(3, 2)).toBe(5); - }); -}); + var socket = function () { + var location = window.parent.location + return window.parent.io.sockets[location.protocol + '//' + location.host] + } + + it('should pass', function () { + expect(1).toBe(1) + }) + + it('should disconnect', function () { + expect(2).toBe(2) + socket().disconnect() + + breath() + }) + + it('should work', function () { + expect(plus(1, 2)).toBe(3) + }) + + it('should re-connect', function () { + expect(4).toBe(4) + socket().reconnect() + // window.parent.socket.socket.connect() + + breath() + }) + + it('should work', function () { + expect(plus(3, 2)).toBe(5) + }) +}) diff --git a/test/e2e/support/timeout/specs.js b/test/e2e/support/timeout/specs.js index 5fb953c47..50e6b53ea 100644 --- a/test/e2e/support/timeout/specs.js +++ b/test/e2e/support/timeout/specs.js @@ -1,5 +1,5 @@ -describe('something', function() { - it('should never happen anyway', function() { - expect(true).toBe(true); - }); -}); +describe('something', function () { + it('should never happen anyway', function () { + expect(true).toBe(true) + }) +}) diff --git a/test/unit/mocks/timer.js b/test/unit/mocks/timer.js index 74c3c14ca..8abb35e9b 100644 --- a/test/unit/mocks/timer.js +++ b/test/unit/mocks/timer.js @@ -1,8 +1,8 @@ -var Timer = require('timer-shim').Timer; +var Timer = require('timer-shim').Timer -module.exports = function() { - var timer = new Timer(); - timer.pause(); +module.exports = function () { + var timer = new Timer() + timer.pause() return { setTimeout: timer.setTimeout, @@ -10,6 +10,5 @@ module.exports = function() { setInterval: timer.setInterval, clearInterval: timer.clearInterval, wind: timer.wind - }; -}; - + } +}