More tests for state-info.html (#256)

* Remove andrey-git keys. Add Android 7.0 emulator

* Use Chrome on Android 7.0

* Try a test that should fail on shadow dom.

* Change test

* try lightOrShadow

* More tests
This commit is contained in:
Andrey
2017-04-08 06:05:13 -07:00
committed by Paulus Schoutsen
parent abbdc6f055
commit 35c086a594
5 changed files with 59 additions and 8 deletions
+1 -1
View File
@@ -9,8 +9,8 @@
<body>
<script>
WCT.loadSuites([
'state-info-test.html',
'state-info-test.html?dom=shadow',
'state-info-test.html?dom=shady',
]);
</script>
</body></html>
+51 -3
View File
@@ -13,15 +13,63 @@
</test-fixture>
<script>
function lightOrShadow(elem, selector) {
return elem.shadowRoot ?
elem.shadowRoot.querySelector(selector) :
elem.querySelector(selector);
}
suite('state-info', function() {
var si;
setup(function() {
si = fixture('state-info');
window.HAWS = {};
window.HAWS.extractDomain = function (entityId) {
return entityId.substr(0, entityId.indexOf('.'));
};
});
test('default stateObj', function() {
assert.equal(si.stateObj, undefined);
test('default values', function() {
assert.isUndefined(si.stateObj);
assert.isUndefined(si.inDialog);
});
test('has state-badge', function() {
assert.isOk(lightOrShadow(si, 'state-badge'));
});
test('stateObj', function(done) {
si.stateObj = {entity_id: 'light.demo', last_changed: '2017-01-01T00:00:00+00:00', state: 'off', attributes: {friendly_name: 'Name'}};
flush(function() {
var stateBadge = lightOrShadow(si, 'state-badge');
assert.isOk(stateBadge);
assert.deepEqual(stateBadge.stateObj, si.stateObj);
var name = lightOrShadow(si, '.name');
assert.isOk(name, '.name missing');
assert.equal(name.textContent, 'Name');
assert.isNotOk(lightOrShadow(si, 'ha-relative-time'));
done();
});
});
test('relative time', function(done) {
si.stateObj = {entity_id: 'light.demo', last_changed: '2017-01-01T00:00:00+00:00', state: 'off', attributes: {friendly_name: 'Name'}};
si.inDialog = true;
flush(function() {
var relativeTime = lightOrShadow(si, 'ha-relative-time');
assert.isOk(relativeTime);
assert.notEqual(relativeTime.textContent, 'never');
assert.notEqual(relativeTime.textContent, '');
si.stateObj = {entity_id: 'light.demo', state: 'off', attributes: {friendly_name: 'Name'}};
flush(function() {
assert.equal(relativeTime.textContent, 'never');
done();
});
});
});
});
</script>