- Much improved API cleanliness and testability to allow further extensibility in future - Simplified code in `live` view This technically contains a small change in how overrides work in the `live` view. Since that change is _closer_ to the documentation, and since this is likely to be rarely used, this is not considered a breaking change. Previously, overrides for a given live camera would always render _as if_ that camera was selected, vs was actually selected. Now, overrides will only apply in the live view when the camera is _actually_ selected. If this is an issue for you in practice, lets discuss.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest';
|
|
import { mock } from 'vitest-mock-extended';
|
|
import { ConditionStateManager } from '../../src/conditions/state-manager';
|
|
import {
|
|
ConditionStateManagerGetEvent,
|
|
getConditionStateManagerViaEvent,
|
|
} from '../../src/conditions/state-manager-via-event';
|
|
|
|
// @vitest-environment jsdom
|
|
describe('getConditionStateManagerViaEvent', () => {
|
|
it('should dispatch event and retrieve state manager', () => {
|
|
const element = document.createElement('div');
|
|
const stateManager = mock<ConditionStateManager>();
|
|
|
|
const handler = vi.fn().mockImplementation((ev: ConditionStateManagerGetEvent) => {
|
|
ev.conditionStateManager = stateManager;
|
|
});
|
|
element.addEventListener(
|
|
'advanced-camera-card:condition-state-manager:get',
|
|
handler,
|
|
);
|
|
|
|
expect(getConditionStateManagerViaEvent(element)).toBe(stateManager);
|
|
});
|
|
|
|
it('should dispatch event and retrieve state manager', () => {
|
|
const element = document.createElement('div');
|
|
|
|
const handler = vi.fn();
|
|
element.addEventListener(
|
|
'advanced-camera-card:condition-state-manager:get',
|
|
handler,
|
|
);
|
|
|
|
expect(getConditionStateManagerViaEvent(element)).toBeNull();
|
|
});
|
|
});
|