@@ -3,7 +3,6 @@ import * as sinon from 'sinon';
33import { ClientKafka } from '../../client/client-kafka' ;
44import { NO_MESSAGE_HANDLER } from '../../constants' ;
55import { KafkaHeaders } from '../../enums' ;
6- import { InvalidKafkaClientTopicPartitionException } from '../../errors/invalid-kafka-client-topic-partition.exception' ;
76import { InvalidKafkaClientTopicException } from '../../errors/invalid-kafka-client-topic.exception' ;
87import {
98 ConsumerGroupJoinEvent ,
@@ -269,6 +268,7 @@ describe('ClientKafka', () => {
269268
270269 expect ( createClientStub . calledOnce ) . to . be . true ;
271270 expect ( producerStub . calledOnce ) . to . be . true ;
271+
272272 expect ( consumerStub . calledOnce ) . to . be . true ;
273273
274274 expect ( on . calledOnce ) . to . be . true ;
@@ -314,13 +314,19 @@ describe('ClientKafka', () => {
314314 memberId : 'member-1' ,
315315 memberAssignment : {
316316 'topic-a' : [ 0 , 1 , 2 ] ,
317+ 'topic-b' : [ 3 , 4 , 5 ] ,
317318 } ,
318319 } ,
319320 } ;
320321
321322 client [ 'setConsumerAssignments' ] ( consumerAssignments ) ;
323+
322324 expect ( client [ 'consumerAssignments' ] ) . to . deep . eq (
323- consumerAssignments . payload . memberAssignment ,
325+ // consumerAssignments.payload.memberAssignment,
326+ {
327+ 'topic-a' : 0 ,
328+ 'topic-b' : 3 ,
329+ } ,
324330 ) ;
325331 } ) ;
326332 } ) ;
@@ -493,30 +499,40 @@ describe('ClientKafka', () => {
493499 } ) ;
494500 } ) ;
495501
502+ describe ( 'getConsumerAssignments' , ( ) => {
503+ it ( 'should get consumer assignments' , ( ) => {
504+ client [ 'consumerAssignments' ] = {
505+ [ replyTopic ] : 0 ,
506+ } ;
507+
508+ const result = client . getConsumerAssignments ( ) ;
509+
510+ expect ( result ) . to . deep . eq ( client [ 'consumerAssignments' ] ) ;
511+ } ) ;
512+ } ) ;
513+
496514 describe ( 'getReplyTopicPartition' , ( ) => {
497515 it ( 'should get reply partition' , ( ) => {
498516 client [ 'consumerAssignments' ] = {
499- [ replyTopic ] : [ 0 ] ,
517+ [ replyTopic ] : 0 ,
500518 } ;
501519
502520 const result = client [ 'getReplyTopicPartition' ] ( replyTopic ) ;
503521
504522 expect ( result ) . to . eq ( '0' ) ;
505523 } ) ;
506524
507- it ( 'should throw error when the topic is being consumed but is not assigned partitions' , ( ) => {
508- client [ 'consumerAssignments' ] = {
509- [ replyTopic ] : [ ] ,
510- } ;
525+ it ( 'should throw error when the topic is not being consumed' , ( ) => {
526+ client [ 'consumerAssignments' ] = { } ;
511527
512528 expect ( ( ) => client [ 'getReplyTopicPartition' ] ( replyTopic ) ) . to . throw (
513- InvalidKafkaClientTopicPartitionException ,
529+ InvalidKafkaClientTopicException ,
514530 ) ;
515531 } ) ;
516532
517- it ( 'should throw error when the topic is not being consumer ' , ( ) => {
533+ it ( 'should throw error when the topic is not being consumed ' , ( ) => {
518534 client [ 'consumerAssignments' ] = {
519- [ topic ] : [ ] ,
535+ [ topic ] : undefined ,
520536 } ;
521537
522538 expect ( ( ) => client [ 'getReplyTopicPartition' ] ( replyTopic ) ) . to . throw (
@@ -568,7 +584,7 @@ describe('ClientKafka', () => {
568584
569585 // set
570586 client [ 'consumerAssignments' ] = {
571- [ replyTopic ] : [ parseFloat ( replyPartition ) ] ,
587+ [ replyTopic ] : parseFloat ( replyPartition ) ,
572588 } ;
573589 } ) ;
574590
0 commit comments