Skip to content

Commit

Permalink
chore: Add back tests for assignWithDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Aug 21, 2023
1 parent 75add4a commit cff9f49
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/mermaid/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,52 @@ describe('when assignWithDepth: should merge objects within objects', function (
boofar: 1,
});
});
it('should handle depth:3 types (merge with clobber because assignWithDepth::depth == 2)', function () {
const config_0 = {
foo: 'bar',
bar: { foo: 'bar', bar: { foo: { message: 'this', willbe: 'clobbered' } } },
boofar: 1,
};
const config_1 = {
foo: 'foo',
bar: { foo: 'foo', bar: { foo: { message: 'clobbered other foo' } } },
foobar: 'foobar',
};
const result = assignWithDepth(config_0, config_1);
expect(result).toEqual({
bar: {
bar: {
foo: {
message: 'clobbered other foo',
willbe: 'clobbered',
},
},
foo: 'foo',
},
boofar: 1,
foo: 'foo',
foobar: 'foobar',
});
});
it('should handle depth:3 types', function () {
const config_0 = {
foo: 'bar',
bar: { foo: 'bar', bar: { foo: { message: '', willbe: 'present' } } },
boofar: 1,
};
const config_1 = {
foo: 'foo',
bar: { foo: 'foo', bar: { foo: { message: 'this' } } },
foobar: 'foobar',
};
const result = assignWithDepth(config_0, config_1);
expect(result).toEqual({
foo: 'foo',
bar: { foo: 'foo', bar: { foo: { message: 'this', willbe: 'present' } } },
foobar: 'foobar',
boofar: 1,
});
});
});
describe('when memoizing', function () {
it('should return the same value', function () {
Expand Down

0 comments on commit cff9f49

Please sign in to comment.