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
15 changes: 14 additions & 1 deletion packages/core/__tests__/internal/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ limitations under the License.

import { describe, expect, test } from '@jest/globals';
import { DIRECTION_MASK, FONT_STYLE_MASK } from '../../src/util/Constants';
import { matchBinaryMask } from '../../src/internal/utils';
import { isNullish, matchBinaryMask } from '../../src/internal/utils';

describe('isNullish', () => {
test.each([null, undefined])('returns true for %s', (value) => {
expect(isNullish(value)).toBeTruthy();
});

test.each([0, false, '', Number.NaN, {}, [], 12, 'hello', { property: 'value' }])(
'returns false for %s',
(value) => {
expect(isNullish(value)).toBeFalsy();
}
);
});

describe('matchBinaryMask', () => {
test('match self', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const isElement = (node?: Node | UserObject | null): node is Element =>
*
* @private not part of the public API, can be removed or changed without prior notice
*/
export const isNullish = (v: unknown): v is null | undefined =>
v === null || v === undefined;
export const isNullish = (v: unknown): v is null | undefined => v == undefined;

/**
* Returns the global logger.
Expand Down