Add client/server version negotiation tests without mocks

* In src/client/index.test.ts added tests:
  - "should connect new client to old, supported server version"
  - should negotiate version when client is old, and newer server supports its version"
  - "should throw when client is old, and server doesn't support its version"
This commit is contained in:
cliffhall 2025-04-28 18:01:14 -04:00
commit d11673fc2d

View file

@ -222,8 +222,6 @@ test("should connect new client to old, supported server version", async () => {
server.connect(serverTransport),
]);
// These should work
// Connection should succeed with the older version
expect(client.getServerVersion()).toEqual({
name: "old server",
version: "1.0",
@ -287,8 +285,6 @@ test("should negotiate version when client is old, and newer server supports its
server.connect(serverTransport),
]);
// These should work
// Connection should succeed with the older version
expect(client.getServerVersion()).toEqual({
name: "new server",
version: "1.0",
@ -348,9 +344,6 @@ test("should throw when client is old, and server doesn't support its version",
},
);
let closed = false;
clientTransport.onerror = () => {closed = true};
await Promise.all([
expect(client.connect(clientTransport)).rejects.toThrow(
"Server's protocol version is not supported: FUTURE_VERSION"