Add eslint mocha options (#671)

* Add eslint mocha options

* Please hound

* Remove deprecated --compiler option
This commit is contained in:
Paulus Schoutsen 2017-11-24 21:01:15 -08:00 committed by GitHub
parent 6c2cd420f5
commit a960559639
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 54 additions and 42 deletions

View File

@ -19,7 +19,8 @@
"webkitSpeechRecognition": false
},
"env": {
"browser": true
"browser": true,
"mocha": true
},
"rules": {
"class-methods-use-this": 0,

View File

@ -3,5 +3,8 @@
"plugins": [
"html",
"react"
]
],
"env": {
"browser": true
}
}

5
test-mocha/.eslintrc Normal file
View File

@ -0,0 +1,5 @@
{
"env": {
"mocha": true
}
}

View File

@ -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'
);
});
});

View File

@ -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',
};

View File

@ -2,13 +2,13 @@ import computeStateDisplay from '../../../js/common/util/compute_state_display';
const assert = require('assert');
describe('computeStateDisplay', function() {
const haLocalize = function(namespace, message, ...args) {
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,8 +29,8 @@ describe('computeStateDisplay', function() {
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.binary_sensor.moisture.off');
});
it('Localizes binary sensor invalid device class', function() {
const altHaLocalize = function(namespace, message, ...args) {
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,8 +141,8 @@ describe('computeStateDisplay', function() {
assert.strictEqual(computeStateDisplay(haLocalize, stateObj, 'en'), 'state.cover.open');
});
it('Localizes unavailable', function() {
const altHaLocalize = function(namespace, message, ...args) {
it('Localizes unavailable', () => {
const altHaLocalize = function (namespace, message, ...args) {
if (namespace === 'state.sensor') return null;
return haLocalize(namespace, message, ...args);
};
@ -155,8 +155,8 @@ describe('computeStateDisplay', function() {
assert.strictEqual(computeStateDisplay(altHaLocalize, stateObj, 'en'), 'state.default.unavailable');
});
it('Localizes custom state', function() {
const altHaLocalize = function(namespace, message, ...args) {
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',

View File

@ -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');
});
});

View File

@ -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');
});
});

View File

@ -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');
});
});

View File

@ -1,5 +1,4 @@
-r reify
--recursive
--compilers js:babel-core/register
--require reify babel-core/register
--timeout 10000
test-mocha