Skip to content

Commit

Permalink
fix(test/client): revert const/let changes.
Browse files Browse the repository at this point in the history
We still test in IE9/10 where the var is king.
  • Loading branch information
johnjbarton authored and lusarz committed Oct 5, 2018
1 parent 637b553 commit c097ecf
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 64 deletions.
6 changes: 3 additions & 3 deletions test/client/karma.conf.js
@@ -1,6 +1,6 @@
const TRAVIS_WITHOUT_BS = process.env.TRAVIS_SECURE_ENV_VARS === 'false'
var TRAVIS_WITHOUT_BS = process.env.TRAVIS_SECURE_ENV_VARS === 'false'

const launchers = {
var launchers = {
bs_chrome: {
base: 'BrowserStack',
browser: 'chrome',
Expand Down Expand Up @@ -59,7 +59,7 @@ const launchers = {
// }
}

let browsers = []
var browsers = []

if (process.env.TRAVIS) {
if (TRAVIS_WITHOUT_BS) {
Expand Down
80 changes: 40 additions & 40 deletions test/client/karma.spec.js
@@ -1,15 +1,15 @@
// shim all the things
require('core-js/es5')
global.JSON = require('json3')
const sinon = require('sinon')
const assert = require('assert')
var sinon = require('sinon')
var assert = require('assert')

const ClientKarma = require('../../client/karma')
const ContextKarma = require('../../context/karma')
const MockSocket = require('./mocks').Socket
var ClientKarma = require('../../client/karma')
var ContextKarma = require('../../context/karma')
var MockSocket = require('./mocks').Socket

describe('Karma', function () {
let socket, k, ck, windowNavigator, windowLocation, windowStub, startSpy, iframe, clientWindow
var socket, k, ck, windowNavigator, windowLocation, windowStub, startSpy, iframe, clientWindow

function setTransportTo (transportName) {
socket._setTransportNameTo(transportName)
Expand All @@ -33,7 +33,7 @@ describe('Karma', function () {
})

it('should start execution when all files loaded and pass config', function () {
const config = ck.config = {
var config = ck.config = {
useIframe: true
}

Expand All @@ -45,7 +45,7 @@ describe('Karma', function () {
})

it('should open a new window when useIFrame is false', function () {
const config = ck.config = {
var config = ck.config = {
useIframe: false,
runInParent: false
}
Expand Down Expand Up @@ -85,13 +85,13 @@ describe('Karma', function () {
})

it('should not set up context if there was an error', function () {
const config = ck.config = {
var config = ck.config = {
clearContext: true
}

socket.emit('execute', config)

const mockWindow = {}
var mockWindow = {}

ck.error('page reload')
ck.setupContext(mockWindow)
Expand All @@ -101,13 +101,13 @@ describe('Karma', function () {
})

it('should setup context if there was error but clearContext config is false', function () {
const config = ck.config = {
var config = ck.config = {
clearContext: false
}

socket.emit('execute', config)

const mockWindow = {}
var mockWindow = {}

ck.error('page reload')
ck.setupContext(mockWindow)
Expand All @@ -118,11 +118,11 @@ describe('Karma', function () {

it('should error out if a script attempted to reload the browser after setup', function () {
// Perform setup
const config = ck.config = {
var config = ck.config = {
clearContext: true
}
socket.emit('execute', config)
const mockWindow = {}
var mockWindow = {}
ck.setupContext(mockWindow)

// Spy on our error handler
Expand All @@ -136,7 +136,7 @@ describe('Karma', function () {
})

it('should report navigator name', function () {
const spyInfo = sinon.spy(function (info) {
var spyInfo = sinon.spy(function (info) {
assert(info.name === 'Fake browser name')
})

Expand All @@ -153,7 +153,7 @@ describe('Karma', function () {
socket = new MockSocket()
k = new ClientKarma(socket, {}, windowStub, windowNavigator, windowLocation)

const spyInfo = sinon.spy(function (info) {
var spyInfo = sinon.spy(function (info) {
assert(info.id === '567')
})

Expand All @@ -165,13 +165,13 @@ describe('Karma', function () {

describe('result', function () {
it('should buffer results when polling', function () {
const spyResult = sinon.stub()
var spyResult = sinon.stub()
socket.on('result', spyResult)

setTransportTo('polling')

// emit 49 results
for (let i = 1; i < 50; i++) {
for (var i = 1; i < 50; i++) {
ck.result({id: i})
}

Expand All @@ -183,13 +183,13 @@ describe('Karma', function () {
})

it('should buffer results when polling', function () {
const spyResult = sinon.stub()
var spyResult = sinon.stub()
socket.on('result', spyResult)

setTransportTo('polling')

// emit 40 results
for (let i = 1; i <= 40; i++) {
for (var i = 1; i <= 40; i++) {
ck.result({id: i})
}

Expand All @@ -199,7 +199,7 @@ describe('Karma', function () {
})

it('should emit "start" with total specs count first', function () {
const log = []
var log = []

socket.on('result', function () {
log.push('result')
Expand All @@ -217,13 +217,13 @@ describe('Karma', function () {
})

it('should not emit "start" if already done by the adapter', function () {
const log = []
var log = []

const spyStart = sinon.spy(function () {
var spyStart = sinon.spy(function () {
log.push('start')
})

const spyResult = sinon.spy(function () {
var spyResult = sinon.spy(function () {
log.push('result')
})

Expand All @@ -243,7 +243,7 @@ describe('Karma', function () {
it('should capture alert', function () {
sinon.spy(ck, 'log')

const mockWindow = {
var mockWindow = {
alert: function () {
throw new Error('Alert was not patched!')
}
Expand All @@ -256,43 +256,43 @@ describe('Karma', function () {

it('should capture confirm', function () {
sinon.spy(ck, 'log')
let confirmCalled = false
var confirmCalled = false

const mockWindow = {
var mockWindow = {
confirm: function () {
confirmCalled = true
return true
}
}

ck.setupContext(mockWindow)
const confirmResult = mockWindow.confirm('What?')
var confirmResult = mockWindow.confirm('What?')
assert(ck.log.calledWith('confirm', ['What?']))
assert.equal(confirmCalled, true)
assert.equal(confirmResult, true)
})

it('should capture prompt', function () {
sinon.spy(ck, 'log')
let promptCalled = false
var promptCalled = false

const mockWindow = {
var mockWindow = {
prompt: function () {
promptCalled = true
return 'user-input'
}
}

ck.setupContext(mockWindow)
const promptResult = mockWindow.prompt('What is your favorite color?', 'blue')
var promptResult = mockWindow.prompt('What is your favorite color?', 'blue')
assert(ck.log.calledWith('prompt', ['What is your favorite color?', 'blue']))
assert.equal(promptCalled, true)
assert.equal(promptResult, 'user-input')
})
})

describe('complete', function () {
let clock
var clock

before(function () {
clock = sinon.useFakeTimers()
Expand All @@ -303,13 +303,13 @@ describe('Karma', function () {
})

it('should clean the result buffer before completing', function () {
const spyResult = sinon.stub()
var spyResult = sinon.stub()
socket.on('result', spyResult)

setTransportTo('polling')

// emit 40 results
for (let i = 0; i < 40; i++) {
for (var i = 0; i < 40; i++) {
ck.result({id: i})
}

Expand Down Expand Up @@ -347,7 +347,7 @@ describe('Karma', function () {
sinon.spy(ck, 'log')
ck.config.captureConsole = true

const mockWindow = {
var mockWindow = {
console: {
log: function () {}
}
Expand All @@ -363,7 +363,7 @@ describe('Karma', function () {
sinon.spy(ck, 'log')
ck.config.captureConsole = false

const mockWindow = {
var mockWindow = {
console: {
log: function () {}
}
Expand All @@ -375,12 +375,12 @@ describe('Karma', function () {
})

it('should clear context window upon complete when clearContext config is true', function () {
const config = ck.config = {
var config = ck.config = {
clearContext: true
}

socket.emit('execute', config)
const CURRENT_URL = iframe.src
var CURRENT_URL = iframe.src

ck.complete()

Expand All @@ -392,12 +392,12 @@ describe('Karma', function () {
})

it('should not clear context window upon complete when clearContext config is false', function () {
const config = ck.config = {
var config = ck.config = {
clearContext: false
}

socket.emit('execute', config)
const CURRENT_URL = iframe.src
var CURRENT_URL = iframe.src

ck.complete()

Expand Down
8 changes: 4 additions & 4 deletions test/client/mocks.js
@@ -1,5 +1,5 @@
function Emitter () {
const listeners = {}
var listeners = {}

this.on = function (event, fn) {
if (!listeners[event]) {
Expand All @@ -10,11 +10,11 @@ function Emitter () {
}

this.emit = function (event) {
const eventListeners = listeners[event]
var eventListeners = listeners[event]

if (!eventListeners) return

let i = 0
var i = 0
while (i < eventListeners.length) {
eventListeners[i].apply(null, Array.prototype.slice.call(arguments, 1))
i++
Expand All @@ -27,7 +27,7 @@ function MockSocket () {

this.socket = {transport: {name: 'websocket'}}

let transportName = 'websocket'
var transportName = 'websocket'

this.io = {
engine: {
Expand Down

0 comments on commit c097ecf

Please sign in to comment.