@samitouri / QOS-React / commits / d779eba4b3

[react-native] Add unit test to ReactNativeAttributePayload (#28955)

## Summary I'm looking at cleaning up some unnecessary manual property flattening in React Native and wanted to verify this behaviour is working as expected, where properties from nested objects will always overwrite properties from the base object. ## How did you test this change? Unit tests

Pieter De Baets committed Apr 29, 2024 at 19:57 UTC d779eba4b375134f373b7dfb9ea98d01c84bc48e
1 file changed +13
packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.internal.js
+13
@@ -204,6 +204,19 @@ describe('ReactNativeAttributePayload', () => {
204 ).toEqual({foo: null}); // this should ideally be null. heuristic.
205 });
206
207 + it('handles attributes defined multiple times', () => {
208 + const validAttributes = {foo: true, style: {foo: true}};
209 + expect(diff({}, {foo: 4, style: {foo: 2}}, validAttributes)).toEqual({
210 + foo: 2,
211 + });
212 + expect(diff({foo: 4}, {style: {foo: 2}}, validAttributes)).toEqual({
213 + foo: 2,
214 + });
215 + expect(diff({style: {foo: 2}}, {foo: 4}, validAttributes)).toEqual({
216 + foo: 4,
217 + });
218 + });
219 +
220 // Function properties are just markers to native that events should be sent.
221 it('should convert functions to booleans', () => {
222 // Note that if the property changes from one function to another, we don't