it('should return error', function (done) { var options = { autoCommit: false, groupId: '_groupId_1_test' }, topics = ['_not_exist_topic_1_test']; var consumer = new Consumer(client, [], options); consumer.on('error', noop); consumer.addTopics(topics, function (err, data) { err.should.equal(1); data.should.eql(topics); done(); }); });
it('should add with given offset', function (done) { var options = { autoCommit: false, groupId: '_groupId_addTopics_test' }, topics = [{topic: EXISTS_TOPIC_2, offset: 42}]; var consumer = new Consumer(client, [], options); consumer.on('error', noop); consumer.addTopics(topics, function (err, data) { data.should.eql(topics.map(function(p) {return p.topic;})); consumer.payloads.some(function (p) { return p.topic === topics[0].topic && p.offset === topics[0].offset; }).should.be.ok; done(); }, true); });
it('should added successfully', function (done) { var options = { autoCommit: false, groupId: '_groupId_addTopics_test' }, topics = ['_exist_topic_2_test']; var consumer = new Consumer(client, [], options); consumer.on('error', noop); consumer.addTopics(topics, function (err, data) { data.should.eql(topics); consumer.payloads.some(function (p) { return p.topic === topics[0] }).should.be.ok; done(); }); });
it('should return error when using payload as well', function (done) { var options = { autoCommit: false, groupId: '_groupId_1_test' }, topics = [{topic: '_not_exist_topic_1_test', offset: 42}]; var consumer = new Consumer(client, [], options); consumer.on('error', noop); consumer.addTopics(topics, function (err) { err.topics.length.should.equal(1); err.topics.should.eql(topics.map(function(p) {return p.topic;})); done(); }, true); });