Skip to content

Commit

Permalink
Add extra tests for topic count example
Browse files Browse the repository at this point in the history
  • Loading branch information
davedoesdev committed Aug 9, 2017
1 parent 340fcc7 commit 738c649
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/topic_count.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,28 @@ describe('qlobber-topic-count', function ()
expect(matcher.topic_count).to.equal(0);
expect(matcher.match('a.b.c').length).to.equal(0);
});

it('should not decrement count if entry does not exist', function ()
{
var matcher = new QlobberTopicCount();
expect(matcher.topic_count).to.equal(0);

matcher.add('foo.bar', 23);
expect(matcher.topic_count).to.equal(1);

matcher.remove('foo.bar', 24);
expect(matcher.topic_count).to.equal(1);

matcher.remove('foo.bar2', 23);
expect(matcher.topic_count).to.equal(1);

matcher.remove('foo.bar', 23);
expect(matcher.topic_count).to.equal(0);

matcher.remove('foo.bar', 24);
expect(matcher.topic_count).to.equal(0);

matcher.remove('foo.bar2', 23);
expect(matcher.topic_count).to.equal(0);
});
});

0 comments on commit 738c649

Please sign in to comment.