diff --git a/test/unit/DataHandler.ts b/test/unit/DataHandler.ts new file mode 100644 index 0000000..850366a --- /dev/null +++ b/test/unit/DataHandler.ts @@ -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); + }); + }); +});