mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-24 04:39:01 +00:00
* Organize files * Import EventsMixin * Import NavigateMixin * Dissolve window.hassMixins * Apply ElementMixin when we use it * Update tests to point at right dir * Eslint * Clean * Update mixins inside hassio * Update lint command" * Fix polymer lint
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
import { assert } from 'chai';
|
|
|
|
import canToggleState from '../../../src/common/entity/can_toggle_state';
|
|
|
|
describe('canToggleState', () => {
|
|
const hass = {
|
|
config: {
|
|
services: {
|
|
light: {
|
|
turn_on: null, // Service keys only need to be present for test
|
|
turn_off: null,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
it('Detects lights toggle', () => {
|
|
const stateObj = {
|
|
entity_id: 'light.bla',
|
|
state: 'on',
|
|
};
|
|
assert.isTrue(canToggleState(hass, stateObj));
|
|
});
|
|
|
|
it('Detects group with toggle', () => {
|
|
const stateObj = {
|
|
entity_id: 'group.bla',
|
|
state: 'on',
|
|
};
|
|
assert.isTrue(canToggleState(hass, stateObj));
|
|
});
|
|
|
|
it('Detects group without toggle', () => {
|
|
const stateObj = {
|
|
entity_id: 'group.devices',
|
|
state: 'home',
|
|
};
|
|
assert.isFalse(canToggleState(hass, stateObj));
|
|
});
|
|
|
|
it('Detects climate with toggle', () => {
|
|
const stateObj = {
|
|
entity_id: 'climate.bla',
|
|
attributes: {
|
|
supported_features: 4096,
|
|
},
|
|
};
|
|
assert.isTrue(canToggleState(hass, stateObj));
|
|
});
|
|
|
|
it('Detects climate without toggle', () => {
|
|
const stateObj = {
|
|
entity_id: 'climate.bla',
|
|
};
|
|
assert.isFalse(canToggleState(hass, stateObj));
|
|
});
|
|
});
|