spec: update callback registry spec to expect (#13263)

* spec: update callback-reg-spec to sexpect

* remove stray only

* remove redundant assertions
This commit is contained in:
Shelley Vohr 2018-06-17 15:08:17 -07:00 committed by GitHub
parent 0ef0e69f03
commit c5c571f8ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,9 @@
const {assert} = require('chai') const chai = require('chai')
const dirtyChai = require('dirty-chai')
const {expect} = chai
chai.use(dirtyChai)
const {CallbacksRegistry} = require('electron') const {CallbacksRegistry} = require('electron')
describe('CallbacksRegistry module', () => { describe('CallbacksRegistry module', () => {
@ -12,7 +17,7 @@ describe('CallbacksRegistry module', () => {
const cb = () => [1, 2, 3, 4, 5] const cb = () => [1, 2, 3, 4, 5]
const key = registry.add(cb) const key = registry.add(cb)
assert.exists(key) expect(key).to.exist()
}) })
it('returns a specified callback if it is in the registry', () => { it('returns a specified callback if it is in the registry', () => {
@ -20,29 +25,23 @@ describe('CallbacksRegistry module', () => {
const key = registry.add(cb) const key = registry.add(cb)
const callback = registry.get(key) const callback = registry.get(key)
assert.equal(callback.toString(), cb.toString()) expect(callback.toString()).equal(cb.toString())
}) })
it('returns an empty function if the cb doesnt exist', () => { it('returns an empty function if the cb doesnt exist', () => {
const callback = registry.get(1) const callback = registry.get(1)
assert.isFunction(callback) expect(callback).to.be.a('function')
}) })
it('removes a callback to the registry', () => { it('removes a callback to the registry', () => {
const cb = () => [1, 2, 3, 4, 5] const cb = () => [1, 2, 3, 4, 5]
const key = registry.add(cb) const key = registry.add(cb)
assert.exists(key)
const beforeCB = registry.get(key)
assert.equal(beforeCB.toString(), cb.toString())
registry.remove(key) registry.remove(key)
const afterCB = registry.get(key) const afterCB = registry.get(key)
assert.isFunction(afterCB) expect(afterCB).to.be.a('function')
assert.notEqual(afterCB.toString(), cb.toString()) expect(afterCB.toString()).to.not.equal(cb.toString())
}) })
}) })