MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / callbackPair

Function callbackPair

javascript/selenium-webdriver/test/lib/testutil.js:44–80  ·  view source on GitHub ↗
(cb, eb)

Source from the content-addressed store, hash-verified

42}
43
44function callbackPair(cb, eb) {
45 if (cb && eb) {
46 throw new TypeError('can only specify one of callback or errback')
47 }
48
49 let callback = cb ? sinon.spy(cb) : sinon.spy()
50 let errback = eb ? sinon.spy(eb) : sinon.spy()
51
52 function assertCallback() {
53 assert.ok(callback.called, 'callback not called')
54 assert.ok(!errback.called, 'errback called')
55 if (callback.threw()) {
56 throw callback.exceptions[0]
57 }
58 }
59
60 function assertErrback() {
61 assert.ok(!callback.called, 'callback called')
62 assert.ok(errback.called, 'errback not called')
63 if (errback.threw()) {
64 throw errback.exceptions[0]
65 }
66 }
67
68 function assertNeither() {
69 assert.ok(!callback.called, 'callback called')
70 assert.ok(!errback.called, 'errback called')
71 }
72
73 return {
74 callback,
75 errback,
76 assertCallback,
77 assertErrback,
78 assertNeither,
79 }
80}
81
82exports.callbackPair = callbackPair
83

Callers 2

testutil.jsFile · 0.85
promise_test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected