The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/ddp-client/__tests__/wrapOnceEventIntoPromise.sp...

25 lines
596 B

import { Emitter } from '@rocket.chat/emitter';
import { wrapOnceEventIntoPromise } from '../src/wrapOnceEventIntoPromise';
it('should resolve', async () => {
const emitter = new Emitter();
const promise = wrapOnceEventIntoPromise(emitter, 'test');
emitter.emit('test', 'test');
const result = await promise;
expect(result).toBe('test');
});
it('should reject', async () => {
const emitter = new Emitter();
const promise = wrapOnceEventIntoPromise(emitter, 'test');
emitter.emit('test', { error: 'test' });
await expect(promise).rejects.toBe('test');
expect.assertions(1);
});