diff --git a/src/api/EventManager.spec.ts b/src/api/EventManager.spec.ts new file mode 100644 index 0000000..c6bc35e --- /dev/null +++ b/src/api/EventManager.spec.ts @@ -0,0 +1,16 @@ +import { EventManager } from "./EventManager"; + +// https://stackoverflow.com/questions/51418086/jest-expected-mock-function-to-have-been-called-but-it-was-not-called +describe('Event Manager', () => { + + it('addEvent should call appropriate REST APIs', () => { + // FIXME: extract to beforeEach + const em = new EventManager; + const newEntry = EventManager.eventFromDefault() + newEntry.state.publishYoutube = false + + expect(em.pu).toHaveBeenCalledTimes(1) + expect(client.publish).toHaveBeenCalledTimes(1) + expect(client.publish).toBeCalledWith('button/islow', '{true}', {qos: 1}) + }) +})