Skip to content

Commit 8dbb31a

Browse files
committed
Test for Server GRPC updated to handle Streaming cases
1 parent 487309c commit 8dbb31a

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

packages/microservices/test/server/server-grpc.spec.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { of } from 'rxjs';
44
import * as sinon from 'sinon';
55
import { InvalidGrpcPackageException } from '../../exceptions/errors/invalid-grpc-package.exception';
66
import { ServerGrpc } from '../../server/server-grpc';
7+
import { GrpcMethodStreamingType } from '@nestjs/microservices';
78

89
describe('ServerGrpc', () => {
910
let server: ServerGrpc;
@@ -125,11 +126,12 @@ describe('ServerGrpc', () => {
125126
it('should return pattern', () => {
126127
const service = 'test';
127128
const method = 'method';
128-
expect(server.createPattern(service, method, false)).to.be.eql(
129+
expect(server.createPattern(service, method, GrpcMethodStreamingType.NO_STREAMING))
130+
.to.be.eql(
129131
JSON.stringify({
130132
service,
131133
rpc: method,
132-
streaming: false
134+
streaming: GrpcMethodStreamingType.NO_STREAMING
133135
}),
134136
);
135137
});
@@ -140,7 +142,11 @@ describe('ServerGrpc', () => {
140142
it('should call "createStreamServiceMethod"', () => {
141143
const cln = sinon.spy();
142144
const spy = sinon.spy(server, 'createStreamServiceMethod');
143-
server.createServiceMethod(cln, { responseStream: true } as any);
145+
server.createServiceMethod(
146+
cln,
147+
{ responseStream: true } as any,
148+
GrpcMethodStreamingType.NO_STREAMING
149+
);
144150

145151
expect(spy.called).to.be.true;
146152
});
@@ -149,7 +155,11 @@ describe('ServerGrpc', () => {
149155
it('should call "createUnaryServiceMethod"', () => {
150156
const cln = sinon.spy();
151157
const spy = sinon.spy(server, 'createUnaryServiceMethod');
152-
server.createServiceMethod(cln, { responseStream: false } as any);
158+
server.createServiceMethod(
159+
cln,
160+
{ responseStream: false } as any,
161+
GrpcMethodStreamingType.NO_STREAMING
162+
);
153163

154164
expect(spy.called).to.be.true;
155165
});

0 commit comments

Comments
 (0)