changes from review
This commit is contained in:
parent
75a117e4e2
commit
933c7330a5
2 changed files with 21 additions and 16 deletions
|
@ -1,7 +1,7 @@
|
|||
const assert = require('assert')
|
||||
const {assert} = require('chai')
|
||||
const {CallbacksRegistry} = require('electron')
|
||||
|
||||
describe('CallbacksRegistry module', () => {
|
||||
describe.only('CallbacksRegistry module', () => {
|
||||
let registry = null
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -10,33 +10,39 @@ describe('CallbacksRegistry module', () => {
|
|||
|
||||
it('adds a callback to the registry', () => {
|
||||
const cb = () => [1, 2, 3, 4, 5]
|
||||
const id = registry.add(cb)
|
||||
assert.equal(id, 1)
|
||||
const key = registry.add(cb)
|
||||
|
||||
assert.exists(key)
|
||||
})
|
||||
|
||||
it('returns a specified callback if it is in the registry', () => {
|
||||
const cb = () => [1, 2, 3, 4, 5]
|
||||
registry.add(cb)
|
||||
const key = registry.add(cb)
|
||||
const callback = registry.get(key)
|
||||
|
||||
const callback = registry.get(1)
|
||||
assert.equal(callback.toString(), cb.toString())
|
||||
})
|
||||
|
||||
it('returns an empty function if the cb doesnt exist', () => {
|
||||
const callback = registry.get(1)
|
||||
assert.equal(callback.toString(), 'function () {}')
|
||||
|
||||
assert.isFunction(callback)
|
||||
})
|
||||
|
||||
it('removes a callback to the registry', () => {
|
||||
const cb = () => [1, 2, 3, 4, 5]
|
||||
const id = registry.add(cb)
|
||||
assert.equal(id, 1)
|
||||
const key = registry.add(cb)
|
||||
|
||||
assert.exists(key)
|
||||
|
||||
const beforeCB = registry.get(key)
|
||||
|
||||
const beforeCB = registry.get(1)
|
||||
assert.equal(beforeCB.toString(), cb.toString())
|
||||
|
||||
registry.remove(1)
|
||||
const afterCB = registry.get(1)
|
||||
assert.equal(afterCB.toString(), 'function () {}')
|
||||
registry.remove(key)
|
||||
const afterCB = registry.get(key)
|
||||
|
||||
assert.isFunction(afterCB)
|
||||
assert.notEqual(afterCB.toString(), cb.toString())
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue