Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitpubnub committed Jan 11, 2024
1 parent e03d14d commit 41383dc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions test/contract/definitions/event-engine.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { after, binding, given, then, when } from 'cucumber-tsflow';
import { DemoKeyset } from '../shared/keysets';
import { PubNub, PubNubManager } from '../shared/pubnub';
import type { MessageEvent, StatusEvent } from 'pubnub';
import type { MessageEvent, PresenceEvent, StatusEvent } from 'pubnub';
import type { Change } from '../../../src/event-engine/core/change';
import { DataTable } from '@cucumber/cucumber';
import { expect } from 'chai';
Expand Down Expand Up @@ -32,6 +32,7 @@ class EventEngineSteps {

private messagePromise?: Promise<MessageEvent>;
private statusPromise?: Promise<StatusEvent>;
private presencePromise?: Promise<PresenceEvent>;
private changelog: Change<any, any>[] = [];
private configuration: any = {};

Expand Down Expand Up @@ -85,10 +86,10 @@ class EventEngineSteps {
});

this.statusPromise = new Promise<StatusEvent>((resolveStatus) => {
this.messagePromise = new Promise<MessageEvent>((resolveMessage) => {
this.presencePromise = new Promise<PresenceEvent>((resolvePresence) => {
this.pubnub?.addListener({
message(messageEvent) {
resolveMessage(messageEvent);
presence(presenceEvent) {
resolvePresence(presenceEvent);
},
status(statusEvent) {
resolveStatus(statusEvent);
Expand All @@ -100,9 +101,9 @@ class EventEngineSteps {
});
}

@then('I wait for getting Presence joined events')
@then('I wait for getting Presence joined events', undefined, 10000)
async thenPresenceJoinEvent() {
const status = await this.messagePromise;
const status = await this.presencePromise;
}

@then('I wait {string} seconds')
Expand Down Expand Up @@ -208,14 +209,14 @@ class EventEngineSteps {
const timetoken = await this.pubnub?.publish({ channel: 'test', message: { content: 'Hello world!' } });
}

@then('I receive an error in my subscribe response')
@then('I receive an error in my subscribe response', undefined, 10000)
async thenIReceiveError() {
const status = await this.statusPromise;

expect(status?.category).to.equal('PNConnectionErrorCategory');
}

@then('I receive the message in my subscribe response')
@then('I receive the message in my subscribe response', undefined, 10000)
async receiveMessage() {
const message = await this.messagePromise;
}
Expand Down
1 change: 1 addition & 0 deletions test/contract/steps/cryptoModule/cryptoModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Then('Successfully decrypt an encrypted file with legacy code', async function (
fileStream.pipe(outputStream);
outputStream.on('end', () => {
const actualFileBuffer = fs.readFileSync(tempFilePath);
//@ts-ignore
expect(actualFileBuffer).to.equalBytes(this.fileDataBuffer);
fs.unlink(tempFilePath, () => {});
});
Expand Down

0 comments on commit 41383dc

Please sign in to comment.