Skip to content

Commit

Permalink
Update tests to remove delay
Browse files Browse the repository at this point in the history
  • Loading branch information
SketchingDev committed Jul 28, 2023
1 parent 6c1887a commit aa3dd47
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import WebSocket from 'ws';
import getPort from 'get-port';
import { WebMessageServerFixture } from './fixtures/WebMessageServerFixture';
import { WebMessageServerConnectionFixture } from './fixtures/WebMessageServerConnectionFixture';
import { NoDelay } from './fixtures/NoDelay';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const FakeTimers = require('@sinonjs/fake-timers');

Expand All @@ -22,6 +23,7 @@ describe('Conversation', () => {
},
{},
() => new WebSocket(`ws://localhost:${genesysServerFixture.port}`),
new NoDelay(),
);

serverConnection = await genesysServerFixture.waitForConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
} from './fixtures/WebMessageServerConnectionFixture';
import { NoDelay } from './fixtures/NoDelay';

describe('Transcriber', () => {
let genesysServerFixture: WebMessageServerFixture;
Expand All @@ -29,6 +30,7 @@ describe('Transcriber', () => {
},
{},
() => new WebSocket(`ws://localhost:${genesysServerFixture.port}`),
new NoDelay(),
);

serverConnection = await genesysServerFixture.waitForConnection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
} from './fixtures/WebMessageServerFixture';
import { NoDelay } from './fixtures/NoDelay';

describe('WebMessengerGuestSession', () => {
let genesysServerFixture: WebMessageServerFixture;
Expand Down Expand Up @@ -50,6 +51,7 @@ describe('WebMessengerGuestSession', () => {
},
{},
() => new WebSocket(`ws://localhost:${genesysServerFixture.port}`),
new NoDelay(),
);

const connectionToServer = await genesysServerFixture.waitForConnection();
Expand All @@ -69,6 +71,7 @@ describe('WebMessengerGuestSession', () => {
},
{},
() => new WebSocket(`ws://localhost:${genesysServerFixture.port}`),
new NoDelay(),
);

const serverConnection = await genesysServerFixture.waitForConnection();
Expand All @@ -94,6 +97,7 @@ describe('WebMessengerGuestSession', () => {
},
{},
() => new WebSocket(`ws://localhost:${genesysServerFixture.port}`),
new NoDelay(),
);

(await genesysServerFixture.waitForConnection()).simulateOutboundTextStructuredMessage(
Expand Down Expand Up @@ -131,6 +135,7 @@ describe('WebMessengerGuestSession', () => {
},
{ test: 'test-value' },
() => new WebSocket(`ws://localhost:${genesysServerFixture.port}`),
new NoDelay(),
);

const serverConnection = await genesysServerFixture.waitForConnection();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { EventEmitter } from 'events';
import { Response } from '../../src/genesys/Response';
import { MessageDelayer } from '../../src/genesys/message-delayer/MessageDelayer';

export class NoDelay extends EventEmitter implements MessageDelayer {
constructor() {
super();
}

public add(message: Response<unknown>): void {
this.emit('message', message);
}
}

0 comments on commit aa3dd47

Please sign in to comment.