test: Split test utilities to improve test times (#2622)
This commit is contained in:
@@ -4,12 +4,9 @@ import { mock } from 'vitest-mock-extended';
|
||||
import type { CameraManagerEngine } from '../../../src/camera-manager/engine';
|
||||
import { TPLinkCamera } from '../../../src/camera-manager/tplink/camera';
|
||||
import type { ActionsExecutor } from '../../../src/card-controller/actions/types';
|
||||
import { createCameraConfig } from '../../config/test-utils';
|
||||
import { EntityRegistryManagerMock } from '../../ha/registry/entity/mock';
|
||||
import {
|
||||
createCameraConfig,
|
||||
createHASSManager,
|
||||
createRegistryEntity,
|
||||
} from '../../test-utils';
|
||||
import { createHASSManager, createRegistryEntity } from '../../test-utils';
|
||||
|
||||
describe('TPLinkCamera', () => {
|
||||
// Entity patterns from: https://github.com/dermotduffy/advanced-camera-card/issues/2183
|
||||
@@ -83,7 +80,7 @@ describe('TPLinkCamera', () => {
|
||||
hassManager: createHASSManager(),
|
||||
entityRegistryManager: new EntityRegistryManagerMock(),
|
||||
}),
|
||||
).rejects.toThrowError('Could not find camera entity');
|
||||
).rejects.toThrow('Could not find camera entity');
|
||||
});
|
||||
|
||||
it('without a matching entity in registry', async () => {
|
||||
@@ -98,7 +95,7 @@ describe('TPLinkCamera', () => {
|
||||
hassManager: createHASSManager(),
|
||||
entityRegistryManager: new EntityRegistryManagerMock(),
|
||||
}),
|
||||
).rejects.toThrowError('Could not find camera entity');
|
||||
).rejects.toThrow('Could not find camera entity');
|
||||
});
|
||||
|
||||
it('successfully with webrtc_card.entity fallback', async () => {
|
||||
@@ -204,7 +201,7 @@ describe('TPLinkCamera', () => {
|
||||
await camera.executePTZAction(executor, 'left', { phase: 'start' }),
|
||||
).toBeFalsy();
|
||||
|
||||
expect(executor.executeActions).not.toBeCalled();
|
||||
expect(executor.executeActions).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should ignore zoom actions (not supported by TPLink)', async () => {
|
||||
@@ -226,7 +223,7 @@ describe('TPLinkCamera', () => {
|
||||
await camera.executePTZAction(executor, 'zoom_out', { phase: 'start' }),
|
||||
).toBeFalsy();
|
||||
|
||||
expect(executor.executeActions).not.toBeCalled();
|
||||
expect(executor.executeActions).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should ignore preset actions (not supported by TPLink)', async () => {
|
||||
@@ -245,7 +242,7 @@ describe('TPLinkCamera', () => {
|
||||
await camera.executePTZAction(executor, 'preset', { preset: 'home' }),
|
||||
).toBeFalsy();
|
||||
|
||||
expect(executor.executeActions).not.toBeCalled();
|
||||
expect(executor.executeActions).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should handle stop phase (no-op for TPLink)', async () => {
|
||||
@@ -265,7 +262,7 @@ describe('TPLinkCamera', () => {
|
||||
await camera.executePTZAction(executor, 'left', { phase: 'stop' }),
|
||||
).toBeTruthy();
|
||||
|
||||
expect(executor.executeActions).not.toBeCalled();
|
||||
expect(executor.executeActions).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -353,7 +350,7 @@ describe('TPLinkCamera', () => {
|
||||
const executor = mock<ActionsExecutor>();
|
||||
await camera.executePTZAction(executor, 'left', { phase: 'start' });
|
||||
|
||||
expect(executor.executeActions).toBeCalledTimes(1);
|
||||
expect(executor.executeActions).toHaveBeenCalledTimes(1);
|
||||
expect(executor.executeActions).toHaveBeenLastCalledWith({
|
||||
actions: {
|
||||
action: 'perform-action',
|
||||
|
||||
Reference in New Issue
Block a user