fix(ignore): Fix tests failing when zhc is linked via pnpm link (#26630)

This commit is contained in:
Koen Kanters
2025-03-06 20:27:17 +00:00
committed by GitHub
parent c603f42c88
commit ad32fec1d0
2 changed files with 9 additions and 11 deletions
+6 -8
View File
@@ -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 () => {