* 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 commit e3509d71823ff5e42a4dcf4849a98c5bb6cb391c. * Revert "Always recalculate state display" This reverts commit 27c24e2694ee6f7c147782532268b3a67998d49b.
65 lines
1.6 KiB
HTML
65 lines
1.6 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
|
<script src="../../web-component-tester/browser.js"></script>
|
|
|
|
<!--
|
|
Temporarily load core.js here so window.HAWS is available. We can remove
|
|
this once hass-util includes the helper function directly.
|
|
-->
|
|
<script src="../build/core.js"></script>
|
|
<link rel="import" href="../src/state-summary/state-card-display.html">
|
|
</head>
|
|
<body>
|
|
<test-fixture id="stateCardDisplay">
|
|
<template>
|
|
<div />
|
|
</template>
|
|
</test-fixture>
|
|
|
|
<script>
|
|
function lightOrShadow(elem, selector) {
|
|
return elem.shadowRoot ?
|
|
elem.shadowRoot.querySelector(selector) :
|
|
elem.querySelector(selector);
|
|
}
|
|
|
|
suite('state-card-display', function() {
|
|
let wrapper;
|
|
let card;
|
|
|
|
setup(function() {
|
|
wrapper = fixture('stateCardDisplay');
|
|
card = new StateCardDisplay();
|
|
card.stateObj = {
|
|
entity_id: 'binary_sensor.demo',
|
|
state: 'off',
|
|
attributes: {
|
|
device_class: 'moisture',
|
|
},
|
|
};
|
|
card.hass = {
|
|
language: 'en',
|
|
resources: {
|
|
'en': {
|
|
'state.binary_sensor.moisture.off': 'Mock Off Text',
|
|
},
|
|
},
|
|
};
|
|
wrapper.appendChild(card);
|
|
});
|
|
|
|
test('state display text', function(done) {
|
|
flush(function() {
|
|
const stateDiv = lightOrShadow(card, '.state');
|
|
assert.isOk(stateDiv);
|
|
assert.deepEqual(stateDiv.innerText, 'Mock Off Text');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|