1
0
mirror of https://github.com/home-assistant/frontend.git synced 2025-12-20 02:38:53 +00:00

Separate more JS util logic to be unit tested (#705)

* 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
This commit is contained in:
Adam Mills
2017-12-03 23:56:16 -05:00
committed by Paulus Schoutsen
parent c1e7f4cc77
commit a723c62f4f
23 changed files with 340 additions and 106 deletions

View File

@@ -7,11 +7,16 @@
*/
import attributeClassNames from './common/util/attribute_class_names.js';
import canToggleDomain from './common/util/can_toggle_domain.js';
import canToggleState from './common/util/can_toggle_state.js';
import computeStateDomain from './common/util/compute_state_domain.js';
import computeStateDisplay from './common/util/compute_state_display.js';
import featureClassNames from './common/util/feature_class_names.js';
import formatDate from './common/util/format_date.js';
import formatDateTime from './common/util/format_date_time.js';
import formatTime from './common/util/format_time.js';
import stateCardType from './common/util/state_card_type.js';
import stateMoreInfoType from './common/util/state_more_info_type.js';
window.hassUtil = window.hassUtil || {};
@@ -21,8 +26,13 @@ const language = navigator.languages ?
window.fecha.masks.haDateTime = window.fecha.masks.shortTime + ' ' + window.fecha.masks.mediumDate;
window.hassUtil.attributeClassNames = attributeClassNames;
window.hassUtil.canToggleDomain = canToggleDomain;
window.hassUtil.canToggleState = canToggleState;
window.hassUtil.computeDomain = computeStateDomain;
window.hassUtil.computeStateDisplay = computeStateDisplay;
window.hassUtil.featureClassNames = featureClassNames;
window.hassUtil.formatDate = dateObj => formatDate(dateObj, language);
window.hassUtil.formatDateTime = dateObj => formatDateTime(dateObj, language);
window.hassUtil.formatTime = dateObj => formatTime(dateObj, language);
window.hassUtil.stateCardType = stateCardType;
window.hassUtil.stateMoreInfoType = stateMoreInfoType;