Skip to content

Commit

Permalink
[react-native] Add unit test to ReactNativeAttributePayload (#28955)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
javache authored Apr 30, 2024
1 parent 190cc99 commit d779eba
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d779eba

Please sign in to comment.