mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 18:06:36 +00:00
Add eslint mocha options (#671)
* Add eslint mocha options * Please hound * Remove deprecated --compiler option
This commit is contained in:
parent
6c2cd420f5
commit
a960559639
@ -19,7 +19,8 @@
|
||||
"webkitSpeechRecognition": false
|
||||
},
|
||||
"env": {
|
||||
"browser": true
|
||||
"browser": true,
|
||||
"mocha": true
|
||||
},
|
||||
"rules": {
|
||||
"class-methods-use-this": 0,
|
||||
|
@ -3,5 +3,8 @@
|
||||
"plugins": [
|
||||
"html",
|
||||
"react"
|
||||
]
|
||||
],
|
||||
"env": {
|
||||
"browser": true
|
||||
}
|
||||
}
|
||||
|
5
test-mocha/.eslintrc
Normal file
5
test-mocha/.eslintrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"env": {
|
||||
"mocha": true
|
||||
}
|
||||
}
|
@ -2,17 +2,18 @@ import attributeClassNames from '../../../js/common/util/attribute_class_names';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('attributeClassNames', function() {
|
||||
describe('attributeClassNames', () => {
|
||||
const attrs = ['mock_attr1', 'mock_attr2'];
|
||||
|
||||
it('Skips null states', function() {
|
||||
it('Skips null states', () => {
|
||||
const stateObj = null;
|
||||
assert.strictEqual(
|
||||
attributeClassNames(stateObj, attrs),
|
||||
'');
|
||||
''
|
||||
);
|
||||
});
|
||||
|
||||
it('Matches no attrbutes', function() {
|
||||
it('Matches no attrbutes', () => {
|
||||
const stateObj = {
|
||||
attributes: {
|
||||
other_attr_1: 1,
|
||||
@ -21,10 +22,11 @@ describe('attributeClassNames', function() {
|
||||
};
|
||||
assert.strictEqual(
|
||||
attributeClassNames(stateObj, attrs),
|
||||
'');
|
||||
''
|
||||
);
|
||||
});
|
||||
|
||||
it('Matches one attrbute', function() {
|
||||
it('Matches one attrbute', () => {
|
||||
const stateObj = {
|
||||
attributes: {
|
||||
other_attr_1: 1,
|
||||
@ -34,10 +36,11 @@ describe('attributeClassNames', function() {
|
||||
};
|
||||
assert.strictEqual(
|
||||
attributeClassNames(stateObj, attrs),
|
||||
'has-mock_attr1');
|
||||
'has-mock_attr1'
|
||||
);
|
||||
});
|
||||
|
||||
it('Matches two attrbutes', function() {
|
||||
it('Matches two attrbutes', () => {
|
||||
const stateObj = {
|
||||
attributes: {
|
||||
other_attr_1: 1,
|
||||
@ -48,6 +51,7 @@ describe('attributeClassNames', function() {
|
||||
};
|
||||
assert.strictEqual(
|
||||
attributeClassNames(stateObj, attrs),
|
||||
'has-mock_attr1 has-mock_attr2');
|
||||
'has-mock_attr1 has-mock_attr2'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -2,8 +2,8 @@ import computeDomain from '../../../js/common/util/compute_domain';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('computeDomain', function() {
|
||||
it('Detects sensor domain', function() {
|
||||
describe('computeDomain', () => {
|
||||
it('Detects sensor domain', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'sensor.test',
|
||||
};
|
||||
|
@ -2,13 +2,13 @@ import computeStateDisplay from '../../../js/common/util/compute_state_display';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('computeStateDisplay', function() {
|
||||
describe('computeStateDisplay', () => {
|
||||
const haLocalize = function (namespace, message, ...args) {
|
||||
// Mock Localize function for testing
|
||||
return namespace + '.' + message + (args.length ? ': ' + args.join(',') : '');
|
||||
};
|
||||
|
||||
it('Localizes binary sensor defaults', function() {
|
||||
it('Localizes binary sensor defaults', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'binary_sensor.test',
|
||||
state: 'off',
|
||||
@ -18,7 +18,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.binary_sensor.default.off');
|
||||
});
|
||||
|
||||
it('Localizes binary sensor device class', function() {
|
||||
it('Localizes binary sensor device class', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'binary_sensor.test',
|
||||
state: 'off',
|
||||
@ -29,7 +29,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.binary_sensor.moisture.off');
|
||||
});
|
||||
|
||||
it('Localizes binary sensor invalid device class', function() {
|
||||
it('Localizes binary sensor invalid device class', () => {
|
||||
const altHaLocalize = function (namespace, message, ...args) {
|
||||
if (namespace === 'state.binary_sensor.invalid_device_class') return null;
|
||||
return haLocalize(namespace, message, ...args);
|
||||
@ -44,7 +44,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(altHaLocalize, stateObj, 'en'), 'state.binary_sensor.default.off');
|
||||
});
|
||||
|
||||
it('Localizes sensor value with units', function() {
|
||||
it('Localizes sensor value with units', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'sensor.test',
|
||||
state: '123',
|
||||
@ -55,7 +55,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), '123 m');
|
||||
});
|
||||
|
||||
it('Localizes input_datetime with full date time', function() {
|
||||
it('Localizes input_datetime with full date time', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'input_datetime.test',
|
||||
state: '123',
|
||||
@ -73,7 +73,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'November 18, 2017, 11:12 AM');
|
||||
});
|
||||
|
||||
it('Localizes input_datetime with date', function() {
|
||||
it('Localizes input_datetime with date', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'input_datetime.test',
|
||||
state: '123',
|
||||
@ -91,7 +91,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'November 18, 2017');
|
||||
});
|
||||
|
||||
it('Localizes input_datetime with time', function() {
|
||||
it('Localizes input_datetime with time', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'input_datetime.test',
|
||||
state: '123',
|
||||
@ -109,7 +109,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), '11:12 AM');
|
||||
});
|
||||
|
||||
it('Localizes zwave ready', function() {
|
||||
it('Localizes zwave ready', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'zwave.test',
|
||||
state: 'ready',
|
||||
@ -120,7 +120,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.zwave.default.ready');
|
||||
});
|
||||
|
||||
it('Localizes zwave initializing', function() {
|
||||
it('Localizes zwave initializing', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'zwave.test',
|
||||
state: 'initializing',
|
||||
@ -131,7 +131,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.zwave.query_stage.initializing: query_stage,Probe');
|
||||
});
|
||||
|
||||
it('Localizes cover open', function() {
|
||||
it('Localizes cover open', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'cover.test',
|
||||
state: 'open',
|
||||
@ -141,7 +141,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.cover.open');
|
||||
});
|
||||
|
||||
it('Localizes unavailable', function() {
|
||||
it('Localizes unavailable', () => {
|
||||
const altHaLocalize = function (namespace, message, ...args) {
|
||||
if (namespace === 'state.sensor') return null;
|
||||
return haLocalize(namespace, message, ...args);
|
||||
@ -155,7 +155,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(altHaLocalize, stateObj, 'en'), 'state.default.unavailable');
|
||||
});
|
||||
|
||||
it('Localizes custom state', function() {
|
||||
it('Localizes custom state', () => {
|
||||
const altHaLocalize = function (namespace, message, ...args) {
|
||||
// No matches can be found
|
||||
return null;
|
||||
@ -169,7 +169,7 @@ describe('computeStateDisplay', function() {
|
||||
assert.strictEqual(computeStateDisplay(altHaLocalize, stateObj, 'en'), 'My Custom State');
|
||||
});
|
||||
|
||||
it('Only calculates state display once per immutable state object', function() {
|
||||
it('Only calculates state display once per immutable state object', () => {
|
||||
const stateObj = {
|
||||
entity_id: 'cover.test',
|
||||
state: 'open',
|
||||
|
@ -2,19 +2,19 @@ import formatDate from '../../../js/common/util/format_date';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('formatDate', function() {
|
||||
describe('formatDate', () => {
|
||||
const dateObj = new Date(
|
||||
2017, 10, 18,
|
||||
11, 12, 13, 1400,
|
||||
);
|
||||
|
||||
it('Formats English dates', function() {
|
||||
it('Formats English dates', () => {
|
||||
assert.strictEqual(formatDate(dateObj, 'en'), 'November 18, 2017');
|
||||
});
|
||||
|
||||
// Node only contains intl support for english formats. This test at least ensures
|
||||
// the fallback to a different locale
|
||||
it('Formats other dates', function() {
|
||||
it('Formats other dates', () => {
|
||||
assert.strictEqual(formatDate(dateObj, 'fr'), '2017 M11 18');
|
||||
});
|
||||
});
|
||||
|
@ -2,19 +2,19 @@ import formatDateTime from '../../../js/common/util/format_date_time';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('formatDateTime', function() {
|
||||
describe('formatDateTime', () => {
|
||||
const dateObj = new Date(
|
||||
2017, 10, 18,
|
||||
11, 12, 13, 1400,
|
||||
);
|
||||
|
||||
it('Formats English date times', function() {
|
||||
it('Formats English date times', () => {
|
||||
assert.strictEqual(formatDateTime(dateObj, 'en'), 'November 18, 2017, 11:12 AM');
|
||||
});
|
||||
|
||||
// Node only contains intl support for english formats. This test at least ensures
|
||||
// the fallback to a different locale
|
||||
it('Formats other date times', function() {
|
||||
it('Formats other date times', () => {
|
||||
assert.strictEqual(formatDateTime(dateObj, 'fr'), '2017 M11 18 11:12');
|
||||
});
|
||||
});
|
||||
|
@ -2,19 +2,19 @@ import formatTime from '../../../js/common/util/format_time';
|
||||
|
||||
const assert = require('assert');
|
||||
|
||||
describe('formatTime', function() {
|
||||
describe('formatTime', () => {
|
||||
const dateObj = new Date(
|
||||
2017, 10, 18,
|
||||
11, 12, 13, 1400,
|
||||
);
|
||||
|
||||
it('Formats English times', function() {
|
||||
it('Formats English times', () => {
|
||||
assert.strictEqual(formatTime(dateObj, 'en'), '11:12 AM');
|
||||
});
|
||||
|
||||
// Node only contains intl support for english formats. This test at least ensures
|
||||
// the fallback to a different locale
|
||||
it('Formats other times', function() {
|
||||
it('Formats other times', () => {
|
||||
assert.strictEqual(formatTime(dateObj, 'fr'), '11:12');
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,4 @@
|
||||
-r reify
|
||||
--recursive
|
||||
--compilers js:babel-core/register
|
||||
--require reify babel-core/register
|
||||
--timeout 10000
|
||||
test-mocha
|
||||
|
Loading…
x
Reference in New Issue
Block a user