Skip to content

Commit d779eba

Browse files
authored
[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
1 parent 190cc99 commit d779eba

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.internal.js

+13
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ describe('ReactNativeAttributePayload', () => {
204204
).toEqual({foo: null}); // this should ideally be null. heuristic.
205205
});
206206

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+
207220
// Function properties are just markers to native that events should be sent.
208221
it('should convert functions to booleans', () => {
209222
// Note that if the property changes from one function to another, we don't

0 commit comments

Comments
 (0)