0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 05:28:35 +00:00
renovatebot_renovate/lib/util/coerce.spec.ts
2023-09-17 06:56:34 +00:00

30 lines
893 B
TypeScript

import { coerceToNull, coerceToUndefined } from './coerce';
describe('util/coerce', () => {
describe('coerceToNull', () => {
it('should return null', () => {
expect(coerceToNull(undefined)).toBeNull();
expect(coerceToNull(null)).toBeNull();
});
it('should return original value', () => {
expect(coerceToNull({})).toEqual({});
expect(coerceToNull('str')).toBe('str');
expect(coerceToNull(false)).toBe(false);
});
});
describe('coerceToUndefined', () => {
it('should return undefined', () => {
expect(coerceToUndefined(undefined)).toBeUndefined();
expect(coerceToUndefined(null)).toBeUndefined();
});
it('should return original value', () => {
expect(coerceToUndefined({})).toEqual({});
expect(coerceToUndefined('str')).toBe('str');
expect(coerceToUndefined(false)).toBe(false);
});
});
});