@relaycorp/ws-mock
Advanced tools
Comparing version 2.5.0 to 2.5.1
@@ -5,2 +5,3 @@ "use strict"; | ||
exports.EmitClientErrorAction = exports.ReceiveMessageAction = exports.SendMessageAction = exports.CloseConnectionAction = exports.AcceptConnectionAction = exports.MockServerAction = void 0; | ||
const events_1 = require("events"); | ||
class MockServerAction { | ||
@@ -17,4 +18,10 @@ constructor() { | ||
this._wasRun = true; | ||
// Allow enough time for the client to process any event emitted by the action | ||
await waitForSetImmediate(); | ||
// Allow enough time for the client to process any event emitted by the action. We would | ||
// normally use setImmediate(), but we can't rely on timer functions because they may be | ||
// mocked (e.g., `jest.useFakeTimers()`). | ||
await new Promise((resolve) => { | ||
const events = new events_1.EventEmitter(); | ||
events.once('done', resolve); | ||
events.emit('done'); | ||
}); | ||
} | ||
@@ -79,5 +86,2 @@ } | ||
exports.EmitClientErrorAction = EmitClientErrorAction; | ||
function waitForSetImmediate() { | ||
return new Promise((resolve) => setImmediate(resolve)); | ||
} | ||
//# sourceMappingURL=MockServerAction.js.map |
// tslint:disable:max-classes-per-file | ||
import { EventEmitter } from 'events'; | ||
export class MockServerAction { | ||
@@ -11,4 +12,10 @@ // tslint:disable-next-line:readonly-keyword | ||
this._wasRun = true; | ||
// Allow enough time for the client to process any event emitted by the action | ||
await waitForSetImmediate(); | ||
// Allow enough time for the client to process any event emitted by the action. We would | ||
// normally use setImmediate(), but we can't rely on timer functions because they may be | ||
// mocked (e.g., `jest.useFakeTimers()`). | ||
await new Promise((resolve) => { | ||
const events = new EventEmitter(); | ||
events.once('done', resolve); | ||
events.emit('done'); | ||
}); | ||
} | ||
@@ -68,5 +75,2 @@ } | ||
} | ||
function waitForSetImmediate() { | ||
return new Promise((resolve) => setImmediate(resolve)); | ||
} | ||
//# sourceMappingURL=MockServerAction.js.map |
{ | ||
"name": "@relaycorp/ws-mock", | ||
"version": "2.5.0", | ||
"version": "2.5.1", | ||
"author": { | ||
@@ -47,3 +47,3 @@ "email": "no-reply@relaycorp.tech", | ||
"tslint": "^5.20.1", | ||
"typedoc": "^0.21.4", | ||
"typedoc": "^0.21.5", | ||
"typescript": "^4.3.5" | ||
@@ -50,0 +50,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63946
1097