Skip to content

Commit

Permalink
Fix app-connector test
Browse files Browse the repository at this point in the history
  • Loading branch information
robknight committed Oct 27, 2024
1 parent 16729db commit 32b3883
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
14 changes: 10 additions & 4 deletions packages/app-connector/test/parcnet-connector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ describe("parcnet-client should work", function () {
const client = new ParcnetRPCConnector(chan.port2, mockDialog);
expect(client.isConnected()).to.be.false;

client.start(() => {
// This is called when the connection is established
expect(client.isConnected()).to.be.true;
});
client.start(
() => {
// This is called when the connection is established
expect(client.isConnected()).to.be.true;
},
() => {
// This is called if the connection fails. We should never get here.
assert(false);
}
);

postRPCMessage(chan.port1, {
type: RPCMessageType.PARCNET_CLIENT_READY
Expand Down
16 changes: 11 additions & 5 deletions packages/app-connector/test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RPCMessageType } from "@parcnet-js/client-rpc";
import { expect } from "vitest";
import { assert, expect } from "vitest";
import type { DialogController } from "../src/adapters/iframe.js";
import { postRPCMessage } from "../src/adapters/iframe.js";
import { ParcnetRPCConnector } from "../src/rpc_client.js";
Expand All @@ -19,10 +19,16 @@ export async function connectedClient(): Promise<{
}> {
const chan = new MessageChannel();
const client = new ParcnetRPCConnector(chan.port2, mockDialog);
client.start(() => {
// This is called when the connection is established
expect(client.isConnected()).to.be.true;
});
client.start(
() => {
// This is called when the connection is established
expect(client.isConnected()).to.be.true;
},
() => {
// This is called if the connection fails. We should never get here.
assert(false);
}
);

postRPCMessage(chan.port1, {
type: RPCMessageType.PARCNET_CLIENT_READY
Expand Down

0 comments on commit 32b3883

Please sign in to comment.