fix vault brokered credentials display (#2583)
* fix: 🐛 brokered credential display in credential panel
This commit is contained in:
1 parent
b049635d28
commit
36c2aee271
6 files changed
+188
-4
No files matched your search
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) HashiCorp, Inc.
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { flattenObject } from 'api/utils/flatten-nested-object';
|
||||
import { module, test } from 'qunit';
|
||||
|
||||
module('Unit | Utility | flatten-nested-object', function () {
|
||||
test('it flattens a nested object to single level object', function (assert) {
|
||||
const input = {
|
||||
a: 1,
|
||||
b: { c: 2, d: 3, e: { f: { g: { h: 10 } } } },
|
||||
};
|
||||
const expected = {
|
||||
a: 1,
|
||||
'b.c': 2,
|
||||
'b.d': 3,
|
||||
'b.e.f.g.h': 10,
|
||||
};
|
||||
assert.deepEqual(flattenObject(input), expected);
|
||||
});
|
||||
|
||||
test('removes keys with null/empty values', function (assert) {
|
||||
const inputOne = {
|
||||
a: null,
|
||||
b: { c: 2 },
|
||||
d: {
|
||||
e: { f: { g: { h: '' } } },
|
||||
},
|
||||
};
|
||||
const inputTwo = {
|
||||
d: { e: null },
|
||||
};
|
||||
const expectedResultOne = {
|
||||
'b.c': 2,
|
||||
};
|
||||
const expectedResultTwo = {};
|
||||
|
||||
assert.deepEqual(flattenObject(inputOne), expectedResultOne);
|
||||
assert.deepEqual(flattenObject(inputTwo), expectedResultTwo);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user