mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-17 02:48:31 -07:00
25 lines
515 B
JavaScript
25 lines
515 B
JavaScript
const events = {};
|
|
|
|
const mock = {
|
|
publish: jest.fn().mockImplementation((topic, payload, options, cb) => cb()),
|
|
end: jest.fn(),
|
|
subscribe: jest.fn(),
|
|
reconnecting: false,
|
|
on: (type, handler) => {
|
|
if (type === 'connect') {
|
|
handler();
|
|
}
|
|
|
|
events[type] = handler
|
|
},
|
|
};
|
|
|
|
const mockConnect = jest.fn().mockReturnValue(mock);
|
|
|
|
jest.mock('mqtt', () => {
|
|
return {connect: mockConnect};
|
|
});
|
|
|
|
module.exports = {
|
|
events, ...mock, connect: mockConnect, mock,
|
|
}; |