mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-02 01:51:38 +00:00
fix(ignore): Fix tests failing when zhc is linked via pnpm link (#26630)
This commit is contained in:
@@ -4,24 +4,23 @@ import {mockMQTTPublishAsync} from '../mocks/mqtt';
|
||||
import {flushPromises} from '../mocks/utils';
|
||||
import {devices, events as mockZHEvents} from '../mocks/zigbeeHerdsman';
|
||||
|
||||
import {MockInstance} from 'vitest';
|
||||
|
||||
import * as zhc from 'zigbee-herdsman-converters';
|
||||
|
||||
import {Controller} from '../../lib/controller';
|
||||
import * as settings from '../../lib/util/settings';
|
||||
|
||||
const mockOnEvent = vi.fn();
|
||||
const mockLivoloOnEvent = vi.fn();
|
||||
// @ts-expect-error mock
|
||||
zhc.onEvent = mockOnEvent;
|
||||
|
||||
const mocksClear = [mockMQTTPublishAsync, mockLogger.warning, mockLogger.debug];
|
||||
const mockOnEvent = vi.spyOn(zhc, 'onEvent');
|
||||
const mocksClear = [mockMQTTPublishAsync, mockLogger.warning, mockLogger.debug, mockOnEvent];
|
||||
|
||||
describe('Extension: OnEvent', () => {
|
||||
let controller: Controller;
|
||||
let mockLivoloOnEvent: MockInstance;
|
||||
|
||||
beforeAll(async () => {
|
||||
const mappedLivolo = (await zhc.findByDevice(devices.LIVOLO))!;
|
||||
mappedLivolo.onEvent = mockLivoloOnEvent;
|
||||
mockLivoloOnEvent = vi.spyOn(mappedLivolo, 'onEvent');
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -39,7 +38,6 @@ describe('Extension: OnEvent', () => {
|
||||
data.writeDefaultConfiguration();
|
||||
settings.reRead();
|
||||
mocksClear.forEach((m) => m.mockClear());
|
||||
mockOnEvent.mockClear();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {devices, groups, events as mockZHEvents} from '../mocks/zigbeeHerdsman';
|
||||
|
||||
import stringify from 'json-stable-stringify-without-jsonify';
|
||||
|
||||
import * as zhcGlobalStore from 'zigbee-herdsman-converters/lib/store';
|
||||
import {clearGlobalStore} from 'zigbee-herdsman-converters';
|
||||
|
||||
import {Controller} from '../../lib/controller';
|
||||
import {loadTopicGetSetRegex} from '../../lib/extension/publish';
|
||||
@@ -58,7 +58,7 @@ describe('Extension: Publish', () => {
|
||||
g.command.mockClear();
|
||||
});
|
||||
|
||||
zhcGlobalStore.clear();
|
||||
clearGlobalStore();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
@@ -1511,7 +1511,7 @@ describe('Extension: Publish', () => {
|
||||
await mockMQTTEvents.message('zigbee2mqtt/bulb_color/set', stringify({state: 'ON', brightness: 20, transition: 0.0}));
|
||||
await flushPromises();
|
||||
|
||||
zhcGlobalStore.clear();
|
||||
clearGlobalStore();
|
||||
|
||||
await mockMQTTEvents.message('zigbee2mqtt/bulb_color/set', stringify({state: 'ON', transition: 1.0}));
|
||||
await flushPromises();
|
||||
|
||||
Reference in New Issue
Block a user