From e74ec93edbb76a8dfca336bd8059c90017e13dcf Mon Sep 17 00:00:00 2001 From: wuxh Date: Wed, 27 Dec 2023 19:40:31 +0800 Subject: [PATCH] chore: replenish unit test case --- src/composeProps.ts | 3 +++ tests/composeProps.test.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/composeProps.ts b/src/composeProps.ts index a72a7350..f89009c0 100644 --- a/src/composeProps.ts +++ b/src/composeProps.ts @@ -1,3 +1,6 @@ +/** + * @description Unsuitable for function methods with return values + */ function composeProps>( originProps: T, patchProps: Partial, diff --git a/tests/composeProps.test.js b/tests/composeProps.test.js index 8fb76dee..73ef7cbc 100644 --- a/tests/composeProps.test.js +++ b/tests/composeProps.test.js @@ -48,4 +48,20 @@ describe('composeProps', () => { 'onDemo', ]); }); + + it('composeProps patch return', () => { + const aChange = jest.fn().mockImplementation(() => 'a'); + const bChange = jest.fn().mockImplementation(() => 'b'); + + const props = composeProps( + { onChange: aChange }, + { onChange: bChange }, // patch return not work (Expected) + ); + + expect(Object.keys(props)).toEqual(['onChange']); + + expect(props.onChange()).toEqual('a'); + expect(aChange).toHaveBeenCalled(); + expect(bChange).toHaveBeenCalled(); + }); });