Skip to content

Commit

Permalink
Add assertions to test
Browse files Browse the repository at this point in the history
  • Loading branch information
aikoven committed Apr 2, 2021
1 parent 4a8f25e commit 8aeee7f
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 8aeee7f

Please sign in to comment.