BlocknoteJS requires an ESM module where our server is CJS, this forced us to pin the server-util version, which led us to force the resolution of several packages, leading to bugs downstream. From Node 22.12 Node supports requiring ESM modules (available from Node 22.0 with a flag). So I upgrade the module. I picked Node 22 and not Node 23 or Node 24 because 22 is the LTS and we don't plan to change node versions frequently. If you remain on Node 18, things should still mostly work, except if you edit a Rich Text field. I also starting changing the default runtime for Serverless Functions which isn't directly related. This means new serverless functions will be created on Node 22, but we will still need another PR to migrate existing serverless functions before September (end of support by AWS). (In this PR I also remove the upgrade commands from 0.43 since they rely on Blocknote and I didn't want to have to deal with this) --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
85 lines
2.6 KiB
TypeScript
85 lines
2.6 KiB
TypeScript
import { isEmptyObject } from '../isEmptyObject';
|
|
|
|
describe('isEmptyObject', () => {
|
|
it('should return true for empty object', () => {
|
|
expect(isEmptyObject({})).toBe(true);
|
|
});
|
|
|
|
it('should return false for object with properties', () => {
|
|
expect(isEmptyObject({ key: 'value' })).toBe(false);
|
|
});
|
|
|
|
it('should return false for object with multiple properties', () => {
|
|
expect(isEmptyObject({ key1: 'value1', key2: 'value2' })).toBe(false);
|
|
});
|
|
|
|
it('should return false for null', () => {
|
|
expect(isEmptyObject(null)).toBe(false);
|
|
});
|
|
|
|
it('should return false for undefined', () => {
|
|
expect(isEmptyObject(undefined)).toBe(false);
|
|
});
|
|
|
|
it('should return false for string', () => {
|
|
expect(isEmptyObject('test')).toBe(false);
|
|
});
|
|
|
|
it('should return false for number', () => {
|
|
expect(isEmptyObject(42)).toBe(false);
|
|
});
|
|
|
|
it('should return false for boolean', () => {
|
|
expect(isEmptyObject(true)).toBe(false);
|
|
expect(isEmptyObject(false)).toBe(false);
|
|
});
|
|
|
|
it('should return true for empty array (as it has no enumerable keys)', () => {
|
|
expect(isEmptyObject([])).toBe(true);
|
|
});
|
|
|
|
it('should return false for non-empty array with enumerable properties', () => {
|
|
const arr = [1, 2, 3];
|
|
expect(isEmptyObject(arr)).toBe(false);
|
|
});
|
|
|
|
it('should return false for function', () => {
|
|
expect(isEmptyObject(() => {})).toBe(false);
|
|
});
|
|
|
|
it('should return true for Date object (as it has no enumerable keys)', () => {
|
|
expect(isEmptyObject(new Date())).toBe(true);
|
|
});
|
|
|
|
it('should return true for object created with Object.create(null)', () => {
|
|
expect(isEmptyObject(Object.create(null))).toBe(true);
|
|
});
|
|
|
|
it('should return true for object with inherited properties only', () => {
|
|
const parent = { parentProp: 'value' };
|
|
const child = Object.create(parent);
|
|
expect(isEmptyObject(child)).toBe(true); // Only checks own enumerable properties
|
|
});
|
|
|
|
it('should return true for object with non-enumerable properties only', () => {
|
|
const obj = {};
|
|
Object.defineProperty(obj, 'nonEnumerableProp', {
|
|
value: 'test',
|
|
enumerable: false,
|
|
});
|
|
expect(isEmptyObject(obj)).toBe(true); // Object.keys only returns enumerable properties
|
|
});
|
|
|
|
it('should return false for array with custom properties', () => {
|
|
const arr: any = [];
|
|
arr.customProp = 'value';
|
|
expect(isEmptyObject(arr)).toBe(false);
|
|
});
|
|
|
|
it('should return false for Date object with custom properties', () => {
|
|
const date: any = new Date();
|
|
date.customProp = 'value';
|
|
expect(isEmptyObject(date)).toBe(false);
|
|
});
|
|
});
|