@@ -112,14 +112,14 @@ describe "app/background", ->
112
112
it "emits 'automation:client:connected'", (done) ->
113
113
client = background.connect("http://localhost:#{PORT}", "/__socket.io")
114
114
115
- @sandbox .spy(client, "emit")
115
+ sinon .spy(client, "emit")
116
116
117
117
client.on "connect", _.once ->
118
118
expect(client.emit).to.be.calledWith("automation:client:connected")
119
119
done()
120
120
121
121
it "listens to cookie changes", (done) ->
122
- addListener = @sandbox .stub(chrome.cookies.onChanged, "addListener")
122
+ addListener = sinon .stub(chrome.cookies.onChanged, "addListener")
123
123
client = background.connect("http://localhost:#{PORT}", "/__socket.io")
124
124
125
125
client.on "connect", _.once ->
@@ -128,10 +128,10 @@ describe "app/background", ->
128
128
129
129
context "onChanged", ->
130
130
it "does not emit when cause is overwrite", (done) ->
131
- addListener = @sandbox .stub(chrome.cookies.onChanged, "addListener")
131
+ addListener = sinon .stub(chrome.cookies.onChanged, "addListener")
132
132
client = background.connect("http://localhost:#{PORT}", "/__socket.io")
133
133
134
- @sandbox .spy(client, "emit")
134
+ sinon .spy(client, "emit")
135
135
136
136
client.on "connect", _.once ->
137
137
fn = addListener.getCall(0).args[0]
@@ -144,7 +144,7 @@ describe "app/background", ->
144
144
it "emits 'automation:push:request'", (done) ->
145
145
info = { cause: "explicit", cookie: {name: "foo", value: "bar"} }
146
146
147
- addListener = @sandbox .stub(chrome.cookies.onChanged, "addListener").yieldsAsync(info)
147
+ addListener = sinon .stub(chrome.cookies.onChanged, "addListener").yieldsAsync(info)
148
148
client = background.connect("http://localhost:#{PORT}", "/__socket.io")
149
149
150
150
client.on "connect", ->
@@ -156,7 +156,7 @@ describe "app/background", ->
156
156
157
157
context ".getAll", ->
158
158
it "resolves with specific cookie properties", ->
159
- @sandbox .stub(chrome.cookies, "getAll")
159
+ sinon .stub(chrome.cookies, "getAll")
160
160
.withArgs({domain: "localhost"})
161
161
.yieldsAsync([
162
162
{name: "foo", value: "f", path: "/", domain: "localhost", secure: true, httpOnly: true, expirationDate: 123}
@@ -175,11 +175,11 @@ describe "app/background", ->
175
175
@code = "var s; (s = document.getElementById('__cypress-string')) && s.textContent"
176
176
177
177
it "resolves on the 1st tab", ->
178
- @sandbox .stub(chrome.tabs, "query")
178
+ sinon .stub(chrome.tabs, "query")
179
179
.withArgs({windowType: "normal"})
180
180
.yieldsAsync([tab1])
181
181
182
- @sandbox .stub(chrome.tabs, "executeScript")
182
+ sinon .stub(chrome.tabs, "executeScript")
183
183
.withArgs(tab1.id, {code: @code})
184
184
.yieldsAsync(["1234"])
185
185
@@ -189,11 +189,11 @@ describe "app/background", ->
189
189
})
190
190
191
191
it "resolves on the 2nd tab", ->
192
- @sandbox .stub(chrome.tabs, "query")
192
+ sinon .stub(chrome.tabs, "query")
193
193
.withArgs({windowType: "normal"})
194
194
.yieldsAsync([tab1, tab2])
195
195
196
- @sandbox .stub(chrome.tabs, "executeScript")
196
+ sinon .stub(chrome.tabs, "executeScript")
197
197
.withArgs(tab1.id, {code: @code})
198
198
.yieldsAsync(["foobarbaz"])
199
199
.withArgs(tab2.id, {code: @code})
@@ -205,7 +205,7 @@ describe "app/background", ->
205
205
})
206
206
207
207
it "filters out tabs that don't start with http", ->
208
- @sandbox .stub(chrome.tabs, "query")
208
+ sinon .stub(chrome.tabs, "query")
209
209
.yieldsAsync([tab3])
210
210
211
211
background.query({
@@ -219,11 +219,11 @@ describe "app/background", ->
219
219
expect(err).to.be.instanceof(Promise.RangeError)
220
220
221
221
it "rejects if no tab matches", ->
222
- @sandbox .stub(chrome.tabs, "query")
222
+ sinon .stub(chrome.tabs, "query")
223
223
.withArgs({windowType: "normal"})
224
224
.yieldsAsync([tab1, tab2])
225
225
226
- @sandbox .stub(chrome.tabs, "executeScript")
226
+ sinon .stub(chrome.tabs, "executeScript")
227
227
.withArgs(tab1.id, {code: @code})
228
228
.yieldsAsync(["foobarbaz"])
229
229
.withArgs(tab2.id, {code: @code})
@@ -241,7 +241,7 @@ describe "app/background", ->
241
241
expect(err).to.be.instanceof(Promise.AggregateError)
242
242
243
243
it "rejects if no tabs were found", ->
244
- @sandbox .stub(chrome.tabs, "query")
244
+ sinon .stub(chrome.tabs, "query")
245
245
.yieldsAsync([])
246
246
247
247
background.query({
@@ -263,7 +263,7 @@ describe "app/background", ->
263
263
264
264
describe "get:cookies", ->
265
265
beforeEach ->
266
- @sandbox .stub(chrome.cookies, "getAll")
266
+ sinon .stub(chrome.cookies, "getAll")
267
267
.withArgs({domain: "google.com"})
268
268
.yieldsAsync([{}, {}])
269
269
@@ -277,7 +277,7 @@ describe "app/background", ->
277
277
278
278
describe "get:cookie", ->
279
279
beforeEach ->
280
- @sandbox .stub(chrome.cookies, "getAll")
280
+ sinon .stub(chrome.cookies, "getAll")
281
281
.withArgs({domain: "google.com", name: "session"})
282
282
.yieldsAsync([
283
283
{name: "session", value: "key", path: "/login", domain: "google", secure: true, httpOnly: true, expirationDate: 123}
@@ -305,7 +305,7 @@ describe "app/background", ->
305
305
beforeEach ->
306
306
chrome.runtime.lastError = {message: "some error"}
307
307
308
- @sandbox .stub(chrome.cookies, "set")
308
+ sinon .stub(chrome.cookies, "set")
309
309
.withArgs({domain: "google.com", name: "session", value: "key", path: "/", secure: false, url: "http://google.com/"})
310
310
.yieldsAsync(
311
311
{name: "session", value: "key", path: "/", domain: "google", secure: false, httpOnly: false}
@@ -358,7 +358,7 @@ describe "app/background", ->
358
358
beforeEach ->
359
359
chrome.runtime.lastError = {message: "some error"}
360
360
361
- @sandbox .stub(chrome.cookies, "getAll")
361
+ sinon .stub(chrome.cookies, "getAll")
362
362
.withArgs({domain: "google.com"})
363
363
.yieldsAsync([
364
364
{name: "session", value: "key", path: "/", domain: "google.com", secure: true, httpOnly: true, expirationDate: 123}
@@ -369,7 +369,7 @@ describe "app/background", ->
369
369
{name: "shouldThrow", value: "key", path: "/assets", domain: "cdn.github.com", secure: false, httpOnly: true, expirationDate: 123}
370
370
])
371
371
372
- @sandbox .stub(chrome.cookies, "remove")
372
+ sinon .stub(chrome.cookies, "remove")
373
373
.withArgs({name: "session", url: "https://google.com/"})
374
374
.yieldsAsync(
375
375
{name: "session", url: "https://google.com/", storeId: "123"}
@@ -417,7 +417,7 @@ describe "app/background", ->
417
417
beforeEach ->
418
418
chrome.runtime.lastError = {message: "some error"}
419
419
420
- @sandbox .stub(chrome.cookies, "getAll")
420
+ sinon .stub(chrome.cookies, "getAll")
421
421
.withArgs({domain: "google.com", name: "session"})
422
422
.yieldsAsync([
423
423
{name: "session", value: "key", path: "/", domain: "google.com", secure: true, httpOnly: true, expirationDate: 123}
@@ -429,7 +429,7 @@ describe "app/background", ->
429
429
{name: "shouldThrow", value: "key", path: "/assets", domain: "cdn.github.com", secure: false, httpOnly: true, expirationDate: 123}
430
430
])
431
431
432
- @sandbox .stub(chrome.cookies, "remove")
432
+ sinon .stub(chrome.cookies, "remove")
433
433
.withArgs({name: "session", url: "https://google.com/"})
434
434
.yieldsAsync(
435
435
{name: "session", url: "https://google.com/", storeId: "123"}
@@ -468,7 +468,7 @@ describe "app/background", ->
468
468
469
469
describe "is:automation:client:connected", ->
470
470
beforeEach ->
471
- @sandbox .stub(chrome.tabs, "query")
471
+ sinon .stub(chrome.tabs, "query")
472
472
.withArgs({url: "CHANGE_ME_HOST/*", windowType: "normal"})
473
473
.yieldsAsync([])
474
474
@@ -482,13 +482,13 @@ describe "app/background", ->
482
482
483
483
describe "take:screenshot", ->
484
484
beforeEach ->
485
- @sandbox .stub(chrome.windows, "getLastFocused").yieldsAsync({id: 1})
485
+ sinon .stub(chrome.windows, "getLastFocused").yieldsAsync({id: 1})
486
486
487
487
afterEach ->
488
488
delete chrome.runtime.lastError
489
489
490
490
it "resolves with screenshot", (done) ->
491
- @sandbox .stub(chrome.tabs, "captureVisibleTab").withArgs(1, {format: "png"}).yieldsAsync("foobarbaz")
491
+ sinon .stub(chrome.tabs, "captureVisibleTab").withArgs(1, {format: "png"}).yieldsAsync("foobarbaz")
492
492
493
493
@socket.on "automation:response", (id, obj = {}) ->
494
494
expect(id).to.eq(123)
@@ -499,7 +499,7 @@ describe "app/background", ->
499
499
500
500
it "rejects with chrome.runtime.lastError", (done) ->
501
501
chrome.runtime.lastError = {message: "some error"}
502
- @sandbox .stub(chrome.tabs, "captureVisibleTab").withArgs(1, {format: "png"}).yieldsAsync(undefined)
502
+ sinon .stub(chrome.tabs, "captureVisibleTab").withArgs(1, {format: "png"}).yieldsAsync(undefined)
503
503
504
504
@socket.on "automation:response", (id, obj = {}) ->
505
505
expect(id).to.eq(123)
0 commit comments