mirror of
https://github.com/status-im/consul.git
synced 2025-01-12 14:55:02 +00:00
6589cbbd0d
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
35 lines
1.7 KiB
JavaScript
35 lines
1.7 KiB
JavaScript
import { selectableKeyValues } from 'consul-ui/helpers/selectable-key-values';
|
|
import { module, test } from 'qunit';
|
|
|
|
module('Unit | Helper | selectable-key-values', function() {
|
|
test('it turns arrays into key values and selects the first item by default', function(assert) {
|
|
const actual = selectableKeyValues([['key-1', 'value-1'], ['key-2', 'value-2']]);
|
|
assert.equal(actual.items.length, 2);
|
|
assert.deepEqual(actual.selected, { key: 'key-1', value: 'value-1' });
|
|
});
|
|
test('it turns arrays into key values and selects the defined key', function(assert) {
|
|
const actual = selectableKeyValues([['key-1', 'value-1'], ['key-2', 'value-2']], {
|
|
selected: 'key-2',
|
|
});
|
|
assert.equal(actual.items.length, 2);
|
|
assert.deepEqual(actual.selected, { key: 'key-2', value: 'value-2' });
|
|
});
|
|
test('it turns arrays into key values and selects the defined index', function(assert) {
|
|
const actual = selectableKeyValues([['key-1', 'value-1'], ['key-2', 'value-2']], {
|
|
selected: 1,
|
|
});
|
|
assert.equal(actual.items.length, 2);
|
|
assert.deepEqual(actual.selected, { key: 'key-2', value: 'value-2' });
|
|
});
|
|
test('it turns arrays with only one element into key values and selects the defined index', function(assert) {
|
|
const actual = selectableKeyValues([['Value 1'], ['Value 2']], { selected: 1 });
|
|
assert.equal(actual.items.length, 2);
|
|
assert.deepEqual(actual.selected, { key: 'value-2', value: 'Value 2' });
|
|
});
|
|
test('it turns strings into key values and selects the defined index', function(assert) {
|
|
const actual = selectableKeyValues(['Value 1', 'Value 2'], { selected: 1 });
|
|
assert.equal(actual.items.length, 2);
|
|
assert.deepEqual(actual.selected, { key: 'value-2', value: 'Value 2' });
|
|
});
|
|
});
|