Skip to content

Commit

Permalink
Update test to account for id change
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Mar 13, 2024
1 parent cc691ac commit 9ca8914
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/extension/__tests__/rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ test("can unsubscribe from a handler by calling the returned function", () => {
const unsubscribe = handle("add", add);

adapter.simulateRPCMessage({
id: 1,
id: "abc",
payload: { type: "add", params: { x: 1, y: 2 } },
});

Expand All @@ -309,7 +309,7 @@ test("can unsubscribe from a handler by calling the returned function", () => {
unsubscribe();

adapter.simulateRPCMessage({
id: 2,
id: "xyz",
payload: { type: "add", params: { x: 1, y: 2 } },
});

Expand Down Expand Up @@ -400,28 +400,28 @@ test("forwards rpc messages from one adapter to another with bridge", () => {
createRPCBridge(adapter1, adapter2);

adapter1.simulateRPCMessage({
id: 1,
id: "abc",
payload: { type: "add", params: { x: 1, y: 2 } },
});

expect(adapter2.postMessage).toHaveBeenCalledTimes(1);
expect(adapter2.postMessage).toHaveBeenCalledWith({
source: "apollo-client-devtools",
type: MessageType.RPC,
id: 1,
id: "abc",
payload: { type: "add", params: { x: 1, y: 2 } },
});

adapter2.simulateRPCMessage({
id: 1,
id: "xyz",
payload: { type: "add", params: { x: 1, y: 2 } },
});

expect(adapter1.postMessage).toHaveBeenCalledTimes(1);
expect(adapter1.postMessage).toHaveBeenCalledWith({
source: "apollo-client-devtools",
type: MessageType.RPC,
id: 1,
id: "xyz",
payload: { type: "add", params: { x: 1, y: 2 } },
});
});
Expand All @@ -433,13 +433,13 @@ test("unsubscribes connection on bridge when calling returned function", () => {
const unsubscribe = createRPCBridge(adapter1, adapter2);

adapter1.simulateRPCMessage({
id: 1,
id: "abc",
payload: { type: "add", params: { x: 1, y: 2 } },
});
expect(adapter2.postMessage).toHaveBeenCalled();

adapter2.simulateRPCMessage({
id: 1,
id: "xyz",
payload: { type: "add", params: { x: 1, y: 2 } },
});
expect(adapter1.postMessage).toHaveBeenCalled();
Expand All @@ -449,13 +449,13 @@ test("unsubscribes connection on bridge when calling returned function", () => {
unsubscribe();

adapter1.simulateRPCMessage({
id: 1,
id: "def",
payload: { type: "add", params: { x: 1, y: 2 } },
});
expect(adapter2.postMessage).not.toHaveBeenCalled();

adapter2.simulateRPCMessage({
id: 1,
id: "uvw",
payload: { type: "add", params: { x: 1, y: 2 } },
});
expect(adapter1.postMessage).not.toHaveBeenCalled();
Expand Down

0 comments on commit 9ca8914

Please sign in to comment.