mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
23 lines
747 B
TypeScript
23 lines
747 B
TypeScript
|
import { AnyEventEmitter } from './anyEventEmitter';
|
||
|
|
||
|
test('AnyEventEmitter', () => {
|
||
|
const events = [];
|
||
|
const results = [];
|
||
|
|
||
|
class MyEventEmitter extends AnyEventEmitter {}
|
||
|
const myEventEmitter = new MyEventEmitter();
|
||
|
|
||
|
myEventEmitter.on('a', () => events.push('a'));
|
||
|
myEventEmitter.on('b', () => events.push('b'));
|
||
|
myEventEmitter.on('c', () => events.push('c'));
|
||
|
myEventEmitter.on('*', () => events.push('*'));
|
||
|
|
||
|
results.push(myEventEmitter.emit('a'));
|
||
|
results.push(myEventEmitter.emit('b'));
|
||
|
results.push(myEventEmitter.emit('c'));
|
||
|
results.push(myEventEmitter.emit('d'));
|
||
|
|
||
|
expect(events).toEqual(['*', 'a', '*', 'b', '*', 'c', '*']);
|
||
|
expect(results).toEqual([true, true, true, false]);
|
||
|
});
|