Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/lib/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ function getDiffType(
return undefined;
}

if (baseline.value === null || target.value === null) {
return 'CHANGED';
}

return getJsonType(baseline.value) === getJsonType(target.value)
? 'CHANGED'
: 'TYPE_CHANGE';
Expand Down
24 changes: 24 additions & 0 deletions test/lib/compare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,30 @@ describe('compareJson', () => {
]);
});

it('reports null comparisons as value changes instead of type changes', () => {
expect(
compareJson(
{ text: null, count: 1 },
{ text: 'ready', count: null },
{ text: null, count: 2 },
),
).toEqual([
{
path: 'count',
type: 'CHANGED',
devValue: 1,
qaValue: null,
prodValue: 2,
},
{
path: 'text',
type: 'CHANGED',
devValue: null,
qaValue: 'ready',
},
]);
});

it('returns separate rows when one environment changes type and another changes value', () => {
expect(
compareJson(
Expand Down
Loading