-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allow consuming code to check if all published events are listened to so no events are missed.
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { test } from 'ava'; | ||
import { TestEmitter, createEvent } from './index'; | ||
|
||
test('no event returns true', t => { | ||
const emitter = new TestEmitter() | ||
t.is(emitter.listenedTo([]), true) | ||
t.is(emitter.listenedTo({}), true) | ||
}) | ||
|
||
test('not listened to event returns false', t => { | ||
const emitter = new TestEmitter() | ||
const c = createEvent('count') | ||
t.is(emitter.listenedTo([c]), false) | ||
t.is(emitter.listenedTo({ c }), false) | ||
t.is(emitter.listenedTo([c.type]), false) | ||
}) | ||
|
||
test('check a listened to event returns true', t => { | ||
const emitter = new TestEmitter() | ||
const c = createEvent('count') | ||
const d = createEvent('dount') | ||
emitter.on(c, () => { return }) | ||
emitter.on(d, () => { return }) | ||
t.is(emitter.listenedTo([c]), true) | ||
t.is(emitter.listenedTo({ c }), true) | ||
t.is(emitter.listenedTo([c.type]), true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters