Skip to content

Commit

Permalink
Add assertions to test
Browse files Browse the repository at this point in the history
  • Loading branch information
aikoven authored and stephenh committed Apr 2, 2021
1 parent e5c34d9 commit e209dcf
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions integration/grpc-js/grpc-js-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,30 +56,40 @@ describe('grpc-js-test', () => {

const client = new TestClient(`localhost:${port}`, ChannelCredentials.createInsecure());

client.unary({}, (err, res) => {});
expect.assertions(4);

const serverStreamingCall = client.serverStreaming({ timestamp: new Date() });
client.unary({}, (err, res) => {
expect(res).toEqual({});
});

const timestamp = new Date();

const serverStreamingCall = client.serverStreaming({ timestamp });
serverStreamingCall.on('data', (response) => {
response.timestamp?.toISOString();
expect(response.timestamp).toEqual(timestamp);
});

const clientStreamingCall = client.clientStreaming((err, res) => {
res.timestamp?.toISOString();
expect(res.timestamp).toEqual(timestamp);
});
clientStreamingCall.write({ timestamp: new Date() });
clientStreamingCall.write({ timestamp });
clientStreamingCall.end();

const bidiStreamingCall = client.bidiStreaming();
bidiStreamingCall.write({ timestamp: new Date() });
bidiStreamingCall.write({ timestamp });
bidiStreamingCall.on('data', (response) => {
response.timestamp?.toISOString();
expect(response.timestamp).toEqual(timestamp);
bidiStreamingCall.end();
});

setTimeout(() => {
server.tryShutdown(() => {
client.close();
});
}, 1000);
await new Promise<void>((resolve) => {
setTimeout(() => {
server.tryShutdown(() => {
client.close();

resolve();
});
}, 100);
});
});
});

0 comments on commit e209dcf

Please sign in to comment.