From acc6c81e3fe1072f307d1f8e0893d3c90bc400eb Mon Sep 17 00:00:00 2001 From: D-Sketon <2055272094@qq.com> Date: Sun, 1 Dec 2024 22:08:16 +0800 Subject: [PATCH] feat(compat): add test for noop and identity --- src/compat/function/identity.spec.ts | 27 +++++++++++++++++++++++++++ src/compat/function/noop.spec.ts | 12 ++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 src/compat/function/identity.spec.ts create mode 100644 src/compat/function/noop.spec.ts diff --git a/src/compat/function/identity.spec.ts b/src/compat/function/identity.spec.ts new file mode 100644 index 000000000..375f2c654 --- /dev/null +++ b/src/compat/function/identity.spec.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from 'vitest'; +import { identity } from '../../function'; + +describe('identity', () => { + it('should return the input value unchanged for a number', () => { + expect(identity(5)).toBe(5); + }); + + it('should return the input value unchanged for a string', () => { + expect(identity('hello')).toBe('hello'); + }); + + it('should return the input value unchanged for an object', () => { + const obj = { key: 'value' }; + expect(identity(obj)).toBe(obj); + }); + + it('should return the input value unchanged for an array', () => { + const arr = [1, 2, 3]; + expect(identity(arr)).toBe(arr); + }); + + it('should return the input value unchanged for a boolean', () => { + expect(identity(true)).toBe(true); + expect(identity(false)).toBe(false); + }); +}); diff --git a/src/compat/function/noop.spec.ts b/src/compat/function/noop.spec.ts new file mode 100644 index 000000000..5e4b2d716 --- /dev/null +++ b/src/compat/function/noop.spec.ts @@ -0,0 +1,12 @@ +import { describe, expect, it } from 'vitest'; +import { noop } from '../../function'; + +describe('noop', () => { + it('should be a function', () => { + expect(typeof noop).toBe('function'); + }); + + it('should return undefined', () => { + expect(noop()).toBeUndefined(); + }); +});