From 25732914f53a793c2bdcb84a97877c4c73efae16 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Mon, 29 Apr 2024 19:46:03 -0700 Subject: [PATCH] [react-native] Add unit test to ReactNativeAttributePayload --- .../ReactNativeAttributePayload-test.internal.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.internal.js index cc61e3a7cee..da43b939c6e 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.internal.js @@ -204,6 +204,19 @@ describe('ReactNativeAttributePayload', () => { ).toEqual({foo: null}); // this should ideally be null. heuristic. }); + it('handles attributes defined multiple times', () => { + const validAttributes = {foo: true, style: {foo: true}}; + expect(diff({}, {foo: 4, style: {foo: 2}}, validAttributes)).toEqual({ + foo: 2, + }); + expect(diff({foo: 4}, {style: {foo: 2}}, validAttributes)).toEqual({ + foo: 2, + }); + expect(diff({style: {foo: 2}}, {foo: 4}, validAttributes)).toEqual({ + foo: 4, + }); + }); + // Function properties are just markers to native that events should be sent. it('should convert functions to booleans', () => { // Note that if the property changes from one function to another, we don't