mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-24 04:39:01 +00:00
* Move computeDomain and format functions to js * Add tests for computeStateDisplay * Always recalculate state display * Remove LANGUAGE from hassUtils object * Move AppLocalizeBehavior import to mixins * Import mixins to state-card-display * Safety check on computeStateDisplay * Don't store computed domains on stateObj * Integration tests for state-card-display * Include extractDomain code in polymer repo * Remove util function null checking * Dont render test element without hass and stateObj * Revert "Don't store computed domains on stateObj" This reverts commite3509d7182. * Revert "Always recalculate state display" This reverts commit27c24e2694.
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
import attributeClassNames from '../../../js/common/util/attribute_class_names';
|
|
|
|
const assert = require('assert');
|
|
|
|
describe('attributeClassNames', function() {
|
|
const attrs = ['mock_attr1', 'mock_attr2'];
|
|
|
|
it('Skips null states', function() {
|
|
const stateObj = null;
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
'');
|
|
});
|
|
|
|
it('Matches no attrbutes', function() {
|
|
const stateObj = {
|
|
attributes: {
|
|
other_attr_1: 1,
|
|
other_attr_2: 2,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
'');
|
|
});
|
|
|
|
it('Matches one attrbute', function() {
|
|
const stateObj = {
|
|
attributes: {
|
|
other_attr_1: 1,
|
|
other_attr_2: 2,
|
|
mock_attr1: 3,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
'has-mock_attr1');
|
|
});
|
|
|
|
it('Matches two attrbutes', function() {
|
|
const stateObj = {
|
|
attributes: {
|
|
other_attr_1: 1,
|
|
other_attr_2: 2,
|
|
mock_attr1: 3,
|
|
mock_attr2: null,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
'has-mock_attr1 has-mock_attr2');
|
|
});
|
|
});
|