* 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
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
import { assert } from 'chai';
|
|
|
|
import attributeClassNames from '../../../js/common/util/attribute_class_names';
|
|
|
|
describe('attributeClassNames', () => {
|
|
const attrs = ['mock_attr1', 'mock_attr2'];
|
|
|
|
it('Skips null states', () => {
|
|
const stateObj = null;
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
''
|
|
);
|
|
});
|
|
|
|
it('Matches no attrbutes', () => {
|
|
const stateObj = {
|
|
attributes: {
|
|
other_attr_1: 1,
|
|
other_attr_2: 2,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
''
|
|
);
|
|
});
|
|
|
|
it('Matches one attrbute', () => {
|
|
const stateObj = {
|
|
attributes: {
|
|
other_attr_1: 1,
|
|
other_attr_2: 2,
|
|
mock_attr1: 3,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
'has-mock_attr1'
|
|
);
|
|
});
|
|
|
|
it('Matches two attrbutes', () => {
|
|
const stateObj = {
|
|
attributes: {
|
|
other_attr_1: 1,
|
|
other_attr_2: 2,
|
|
mock_attr1: 3,
|
|
mock_attr2: null,
|
|
},
|
|
};
|
|
assert.strictEqual(
|
|
attributeClassNames(stateObj, attrs),
|
|
'has-mock_attr1 has-mock_attr2'
|
|
);
|
|
});
|
|
});
|