Skip to content

Commit

Permalink
add Datahandler constructor test
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Zinin <[email protected]>
  • Loading branch information
pinkiesky committed Oct 23, 2024
1 parent 376d395 commit 7475bb9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/unit/DataHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as sinon from "sinon";
import { expect } from "chai";
import DataHandler from "../../lib/DataHandler";

describe("DataHandler", () => {
afterEach(() => {
sinon.restore();
});

describe("constructor()", () => {
it("should add a data handler to the redis stream properly", () => {
const dataHandledable = {
stream: {
prependListener: sinon.spy(),
resume: sinon.spy(),
},
};
new DataHandler(dataHandledable, {});

expect(dataHandledable.stream.prependListener.calledOnce).to.eql(true);
expect(dataHandledable.stream.resume.calledOnce).to.eql(true);

expect(
dataHandledable.stream.resume.calledAfter(
dataHandledable.stream.prependListener
)
).to.eql(true);
});
});
});

0 comments on commit 7475bb9

Please sign in to comment.