Skip to content

Commit

Permalink
test(microservices): update outdated listeners controller test
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed May 17, 2022
1 parent cf42ed5 commit 34143d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/microservices/listeners-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class ListenersController {
transport === server.transportId,
)
.reduce((acc, handler) => {
handler.patterns.forEach(pattern =>
// Optional chaining for backward-compatibility
handler.patterns?.forEach(pattern =>
acc.push({ ...handler, patterns: [pattern] }),
);
return acc;
Expand Down
8 changes: 6 additions & 2 deletions packages/microservices/test/listeners-controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,15 @@ describe('ListenersController', () => {
it(`should call "addHandler" method of server with custom transportID for pattern handler with the same custom token`, () => {
const serverHandlers = [
{
pattern: { cmd: 'test' },
patterns: [{ cmd: 'test' }],
targetCallback: 'tt',
transport: customTransport,
},
{ pattern: 'test2', targetCallback: '2', transport: Transport.KAFKA },
{
patterns: ['test2'],
targetCallback: '2',
transport: Transport.KAFKA,
},
];

explorer.expects('explore').returns(serverHandlers);
Expand Down

0 comments on commit 34143d9

Please sign in to comment.