Add test for duplicate events

This commit is contained in:
Jouni Airaksinen 2020-09-07 14:14:53 +03:00
parent b5f582ee1a
commit d5c8a25a08

View file

@ -29,6 +29,19 @@ describe("Emitter", () => {
emitter.dispose();
});
it("can unbind duplicate events", () => {
const emitter = new Emitter();
const callback = () => {
throw new Error("should call this");
};
emitter.on("something", callback);
emitter.on("something", callback);
emitter.on("something", callback);
emitter.off("something", callback);
emitter.emit("something");
emitter.dispose();
});
it("'off' does nothing if there is no event scheduled", () => {
const emitter = new Emitter();
const callback = () => {