wip: first draft for jest test EventManager

This commit is contained in:
Frieder Schlesier 2023-02-12 13:55:53 +01:00
parent 56443f2b71
commit ef5e4acb90
1 changed files with 16 additions and 0 deletions

View File

@ -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})
})
})