Files
ontime/apps/server/src/utils/__tests__/parserUtils.test.ts
T
2025-05-14 20:07:42 +02:00

35 lines
847 B
TypeScript

import { isEmptyObject, removeUndefined } from '../parserUtils.js';
describe('isEmptyObject()', () => {
test('finds an empty object', () => {
const isEmpty = isEmptyObject({});
expect(isEmpty).toBe(true);
});
test('resolves an object with methods', () => {
const isEmpty = isEmptyObject({ test: 'yes' });
expect(isEmpty).toBe(false);
});
});
describe('removeUndefined()', () => {
test('it removes undefined keys from object', () => {
const obj = {
first: 'yes',
second: undefined,
third: 'yes',
};
expect(removeUndefined(obj)).toStrictEqual({
first: 'yes',
third: 'yes',
});
});
test('it handles falsy values object', () => {
const obj = {
first: '',
second: 0,
third: 'null',
};
expect(removeUndefined(obj)).toStrictEqual(obj);
});
});