* 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
57 lines
1.1 KiB
JavaScript
57 lines
1.1 KiB
JavaScript
import { assert } from 'chai';
|
|
|
|
import featureClassNames from '../../../js/common/util/feature_class_names';
|
|
|
|
describe('featureClassNames', () => {
|
|
const classNames = {
|
|
1: 'has-feature_a',
|
|
2: 'has-feature_b',
|
|
4: 'has-feature_c',
|
|
8: 'has-feature_d',
|
|
};
|
|
|
|
it('Skips null states', () => {
|
|
const stateObj = null;
|
|
assert.strictEqual(
|
|
featureClassNames(stateObj, classNames),
|
|
''
|
|
);
|
|
});
|
|
|
|
it('Matches no features', () => {
|
|
const stateObj = {
|
|
attributes: {
|
|
supported_features: 64,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
featureClassNames(stateObj, classNames),
|
|
''
|
|
);
|
|
});
|
|
|
|
it('Matches one feature', () => {
|
|
const stateObj = {
|
|
attributes: {
|
|
supported_features: 72,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
featureClassNames(stateObj, classNames),
|
|
'has-feature_d'
|
|
);
|
|
});
|
|
|
|
it('Matches two features', () => {
|
|
const stateObj = {
|
|
attributes: {
|
|
supported_features: 73,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
featureClassNames(stateObj, classNames),
|
|
'has-feature_a has-feature_d'
|
|
);
|
|
});
|
|
});
|