mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 02:38:53 +00:00
* Move featureClassNames to js util * Add tests for featureClassNames * Strip empty feature class names * Move canToggleDomain to js util * Add tests for canToggleDomain * Refactor canToggleDomain to ensure boolean return * Switch to chai assert for richer syntax options * Move canToggleState to js util * Tests for canToggleState * Enable linting for mocha tests * Move stateCardType to js util * Add tests for stateCardType * Move stateMoreInfoType to js util * Tests for stateMoreInfoType * Include mdn Array includes polyfill
40 lines
894 B
JavaScript
40 lines
894 B
JavaScript
import { assert } from 'chai';
|
|
|
|
import canToggleDomain from '../../../js/common/util/can_toggle_domain';
|
|
|
|
describe('canToggleDomain', () => {
|
|
const hass = {
|
|
config: {
|
|
services: {
|
|
light: {
|
|
turn_on: null, // Service keys only need to be present for test
|
|
turn_off: null,
|
|
},
|
|
lock: {
|
|
lock: null,
|
|
unlock: null,
|
|
},
|
|
sensor: {
|
|
custom_service: null,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
it('Detects lights toggle', () => {
|
|
assert.isTrue(canToggleDomain(hass, 'light'));
|
|
});
|
|
|
|
it('Detects locks toggle', () => {
|
|
assert.isTrue(canToggleDomain(hass, 'lock'));
|
|
});
|
|
|
|
it('Detects sensors do not toggle', () => {
|
|
assert.isFalse(canToggleDomain(hass, 'sensor'));
|
|
});
|
|
|
|
it('Detects binary sensors do not toggle', () => {
|
|
assert.isFalse(canToggleDomain(hass, 'binary_sensor'));
|
|
});
|
|
});
|