fix: Do not show [object Object] in error message when validating type (no-changelog) (#9591)

This commit is contained in:
Michael Kret
2024-06-03 12:09:48 +03:00
committed by GitHub
parent 19e5c0397a
commit cda1e3f6e5
3 changed files with 29 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { validateFieldType } from '@/TypeValidation';
import { getValueDescription, validateFieldType } from '@/TypeValidation';
import { DateTime } from 'luxon';
const VALID_ISO_DATES = [
@@ -230,4 +230,15 @@ describe('Type Validation', () => {
});
});
});
describe('getValueDescription util function', () => {
it('should return correct description', () => {
expect(getValueDescription('foo')).toBe("'foo'");
expect(getValueDescription(42)).toBe("'42'");
expect(getValueDescription(true)).toBe("'true'");
expect(getValueDescription(null)).toBe("'null'");
expect(getValueDescription(undefined)).toBe("'undefined'");
expect(getValueDescription([{}])).toBe('array');
expect(getValueDescription({})).toBe('object');
});
});
});