refactor: Retire the use of unmaintained custom-card-helpers (#1956)
- Closes #1295
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { computeDomain } from '../../src/ha/compute-domain.js';
|
||||
|
||||
describe('computeDomain', () => {
|
||||
it('should return the domain of an entity ID', () => {
|
||||
expect(computeDomain('light.kitchen')).toBe('light');
|
||||
expect(computeDomain('sensor.temperature')).toBe('sensor');
|
||||
expect(computeDomain('switch.garage')).toBe('switch');
|
||||
});
|
||||
|
||||
it('should return an empty string if there is no dot in the entity ID', () => {
|
||||
expect(computeDomain('invalidEntityId')).toBe('');
|
||||
});
|
||||
|
||||
it('should handle entity IDs with multiple dots correctly', () => {
|
||||
expect(computeDomain('light.kitchen.ceiling')).toBe('light');
|
||||
});
|
||||
|
||||
it('should return an empty string for an empty entity ID', () => {
|
||||
expect(computeDomain('')).toBe('');
|
||||
});
|
||||
|
||||
it('should return an empty string for a dot-only entity ID', () => {
|
||||
expect(computeDomain('.')).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { fireHASSEvent } from '../../src/ha/fire-hass-event.js';
|
||||
import { forwardHaptic, HapticType } from '../../src/ha/haptic.js';
|
||||
|
||||
vi.mock('../../src/ha/fire-hass-event.js', () => ({
|
||||
fireHASSEvent: vi.fn(),
|
||||
}));
|
||||
|
||||
// @vitest-environment jsdom
|
||||
describe('forwardHaptic', () => {
|
||||
it.each([
|
||||
['success' as const],
|
||||
['warning' as const],
|
||||
['failure' as const],
|
||||
['light' as const],
|
||||
['medium' as const],
|
||||
['heavy' as const],
|
||||
['selection' as const],
|
||||
])('should call fireHASSEvent with %s', (hapticType: HapticType) => {
|
||||
forwardHaptic(hapticType);
|
||||
|
||||
expect(fireHASSEvent).toBeCalledWith(window, 'haptic', hapticType);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user