test: ensure legacy callback functions work (#16436)
* test: test legacy callback functions * add TODO removal comments * fix callback spec
This commit is contained in:
parent
720197f9c8
commit
f105c84349
6 changed files with 114 additions and 9 deletions
|
@ -656,17 +656,33 @@ describe('protocol module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('protocol.isProtocolHandled', () => {
|
||||
describe('protocol.isProtocolHandled', (done) => {
|
||||
it('returns true for about:', async () => {
|
||||
const result = await protocol.isProtocolHandled('about')
|
||||
assert.strictEqual(result, true)
|
||||
})
|
||||
|
||||
// TODO(codebytere): remove when promisification is complete
|
||||
it('returns true for about: (callback)', () => {
|
||||
protocol.isProtocolHandled('about', (result) => {
|
||||
assert.strictEqual(result, true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('returns true for file:', async () => {
|
||||
const result = await protocol.isProtocolHandled('file')
|
||||
assert.strictEqual(result, true)
|
||||
})
|
||||
|
||||
// TODO(codebytere): remove when promisification is complete
|
||||
it('returns true for file: (callback)', () => {
|
||||
protocol.isProtocolHandled('file', (result) => {
|
||||
assert.strictEqual(result, true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('returns true for http:', async () => {
|
||||
const result = await protocol.isProtocolHandled('http')
|
||||
assert.strictEqual(result, true)
|
||||
|
@ -682,7 +698,7 @@ describe('protocol module', () => {
|
|||
assert.strictEqual(result, false)
|
||||
})
|
||||
|
||||
it('returns true for custom protocol', (done) => {
|
||||
it('returns true for custom protocol', () => {
|
||||
const emptyHandler = (request, callback) => callback()
|
||||
protocol.registerStringProtocol(protocolName, emptyHandler, async (error) => {
|
||||
assert.strictEqual(error, null)
|
||||
|
@ -692,7 +708,19 @@ describe('protocol module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
it('returns true for intercepted protocol', (done) => {
|
||||
// TODO(codebytere): remove when promisification is complete
|
||||
it('returns true for custom protocol (callback)', () => {
|
||||
const emptyHandler = (request, callback) => callback()
|
||||
protocol.registerStringProtocol(protocolName, emptyHandler, (error) => {
|
||||
assert.strictEqual(error, null)
|
||||
protocol.isProtocolHandled(protocolName, (result) => {
|
||||
assert.strictEqual(result, true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('returns true for intercepted protocol', () => {
|
||||
const emptyHandler = (request, callback) => callback()
|
||||
protocol.interceptStringProtocol('http', emptyHandler, async (error) => {
|
||||
assert.strictEqual(error, null)
|
||||
|
@ -701,6 +729,18 @@ describe('protocol module', () => {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
// TODO(codebytere): remove when promisification is complete
|
||||
it('returns true for intercepted protocol (callback)', () => {
|
||||
const emptyHandler = (request, callback) => callback()
|
||||
protocol.interceptStringProtocol('http', emptyHandler, (error) => {
|
||||
assert.strictEqual(error, null)
|
||||
protocol.isProtocolHandled('http', (result) => {
|
||||
assert.strictEqual(result, true)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('protocol.intercept(Any)Protocol', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue