forked from Github/frigate
Abstract MQTT from communication and make mqtt optional (#4462)
* Add option for mqtt config * Setup communication layer * Have a dispatcher which is responsible for handling and sending messages * Move mqtt to communication * Separate ws communications module * Make ws client conform to communicator * Cleanup imports * Migrate to new dispatcher * Clean up * Need to set topic prefix * Remove references to mqtt in dispatcher * Don't start mqtt until dispatcher is subscribed * Cleanup * Shorten package * Formatting * Remove unused * Cleanup * Rename mqtt to ws on web * Fix ws mypy * Fix mypy * Reformat * Cleanup if/else chain * Catch bad set commands
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import { h } from 'preact';
|
||||
import * as CameraImage from '../../components/CameraImage';
|
||||
import * as Mqtt from '../../api/mqtt';
|
||||
import * as WS from '../../api/ws';
|
||||
import Cameras from '../Cameras';
|
||||
import { fireEvent, render, screen, waitForElementToBeRemoved } from 'testing-library';
|
||||
|
||||
describe('Cameras Route', () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(CameraImage, 'default').mockImplementation(() => <div data-testid="camera-image" />);
|
||||
vi.spyOn(Mqtt, 'useMqtt').mockImplementation(() => ({ value: { payload: 'OFF' }, send: vi.fn() }));
|
||||
vi.spyOn(WS, 'useWs').mockImplementation(() => ({ value: { payload: 'OFF' }, send: vi.fn() }));
|
||||
});
|
||||
|
||||
test('shows an ActivityIndicator if not yet loaded', async () => {
|
||||
@@ -39,13 +39,13 @@ describe('Cameras Route', () => {
|
||||
const sendDetect = vi.fn();
|
||||
const sendRecordings = vi.fn();
|
||||
const sendSnapshots = vi.fn();
|
||||
vi.spyOn(Mqtt, 'useDetectState').mockImplementation(() => {
|
||||
vi.spyOn(WS, 'useDetectState').mockImplementation(() => {
|
||||
return { payload: 'ON', send: sendDetect };
|
||||
});
|
||||
vi.spyOn(Mqtt, 'useRecordingsState').mockImplementation(() => {
|
||||
vi.spyOn(WS, 'useRecordingsState').mockImplementation(() => {
|
||||
return { payload: 'OFF', send: sendRecordings };
|
||||
});
|
||||
vi.spyOn(Mqtt, 'useSnapshotsState').mockImplementation(() => {
|
||||
vi.spyOn(WS, 'useSnapshotsState').mockImplementation(() => {
|
||||
return { payload: 'ON', send: sendSnapshots };
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user