aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Miller <[email protected]>2017-02-25 15:47:06 -0500
committerJason Miller <[email protected]>2017-02-25 15:47:06 -0500
commit454011654f831d9d70cb434fadd606483d26cf60 (patch)
treef45bfe6c5bd77ffc1b294c83f1728b8cadf7c11c /test
parent29c4aa1f9afec23dcccdc754dc581fb8f64a0e19 (diff)
Use sinon-chai methods for assertions
Diffstat (limited to 'test')
-rw-r--r--test/index.js43
1 files changed, 18 insertions, 25 deletions
diff --git a/test/index.js b/test/index.js
index 7c5c429..8863dd2 100644
--- a/test/index.js
+++ b/test/index.js
@@ -112,38 +112,31 @@ describe('mitt#', () => {
});
it('should NOT ignore case', () => {
- let foo = spy(),
- bar = spy(),
- num = 123;
- events.Foo = [foo];
- events.FOO = [bar];
-
- inst.emit('FOO', num);
- inst.emit('Foo', num);
-
- let args1 = foo.args[0];
- let args2 = bar.args[0];
-
- expect(foo).to.have.been.calledOnce;
- expect(bar).to.have.been.calledOnce;
- expect(args1).to.be.deep.equal([num]);
- expect(args2).to.be.deep.equal([num]);
+ let onFoo = spy(),
+ onFOO = spy();
+ events.Foo = [onFoo];
+ events.FOO = [onFOO];
+
+ inst.emit('Foo', 'Foo arg');
+ inst.emit('FOO', 'FOO arg');
+
+ expect(onFoo).to.have.been.calledOnce.and.calledWith('Foo arg');
+ expect(onFOO).to.have.been.calledOnce.and.calledWith('FOO arg');
});
it('should invoke * handlers', () => {
let star = spy(),
- aa = 'bb';
- events['*'] = [star];
+ ea = { a: 'a' },
+ eb = { b: 'b' };
- inst.emit('foo', aa);
- inst.emit('bar', aa);
+ events['*'] = [star];
- let args1 = star.args[0],
- args2 = star.args[1];
+ inst.emit('foo', ea);
+ expect(star).to.have.been.calledOnce.and.calledWith('foo', ea);
+ star.reset();
- expect(star).to.have.been.calledTwice;
- expect(args1).to.deep.equal(['foo', aa]);
- expect(args2).to.deep.equal(['bar', aa]);
+ inst.emit('bar', eb);
+ expect(star).to.have.been.calledOnce.and.calledWith('bar', eb);
});
});
});