mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-09 06:55:03 +00:00
Added testcases for mergeEnvironmentVariables method
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
const { flattenDataForDotNotation } = require('../../src/utils/common');
|
const { flattenDataForDotNotation, mergeEnvironmentVariables } = require('../../src/utils/common');
|
||||||
|
|
||||||
describe('utils: flattenDataForDotNotation', () => {
|
describe('utils: flattenDataForDotNotation', () => {
|
||||||
test('Flatten a simple object with dot notation', () => {
|
test('Flatten a simple object with dot notation', () => {
|
||||||
@@ -82,4 +82,29 @@ describe('utils: flattenDataForDotNotation', () => {
|
|||||||
|
|
||||||
expect(flattenDataForDotNotation(input)).toEqual(expectedOutput);
|
expect(flattenDataForDotNotation(input)).toEqual(expectedOutput);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe('utils: mergeEnvironmentVariables', () => {
|
||||||
|
test('Merge two objects', () => {
|
||||||
|
const obj1 = { a: 1, b: 2 };
|
||||||
|
const obj2 = { c: 3, d: 4 };
|
||||||
|
const merged = mergeEnvironmentVariables(obj1, obj2);
|
||||||
|
expect(merged).toEqual({ a: 1, b: 2, c: 3, d: 4 });
|
||||||
|
});
|
||||||
|
// test merge objects with redundant keys
|
||||||
|
test('Merge objects with redundant keys', () => {
|
||||||
|
const obj1 = { a: 1, b: 2 };
|
||||||
|
const obj2 = { b: 3, c: 4 };
|
||||||
|
const merged = mergeEnvironmentVariables(obj1, obj2);
|
||||||
|
expect(merged).toEqual({ a: 1, b: 3, c: 4 });
|
||||||
|
});
|
||||||
|
// test merge objects with multiple redundant keys
|
||||||
|
test('Merge objects with multiple redundant keys', () => {
|
||||||
|
const obj1 = { a: 1, b: 2 };
|
||||||
|
const obj2 = { b: 3, c: 4 };
|
||||||
|
const obj3 = { c: 5, d: 6 };
|
||||||
|
const merged = mergeEnvironmentVariables(obj1, obj2, obj3);
|
||||||
|
expect(merged).toEqual({ a: 1, b: 3, c: 5, d: 6 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user