diff --git a/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap b/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap index d630684f..41a07887 100644 --- a/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap +++ b/packages/react-native-web/src/exports/View/__tests__/__snapshots__/index-test.js.snap @@ -126,6 +126,49 @@ exports[`components/View prop "pointerEvents" 1`] = ` /> `; +exports[`components/View prop "ref" setNativeProps method style updates as expected 1`] = ` +
+`; + +exports[`components/View prop "ref" setNativeProps method style updates as expected 2`] = ` +
+`; + +exports[`components/View prop "ref" setNativeProps method style updates as expected 3`] = ` +
+`; + +exports[`components/View prop "ref" setNativeProps method style updates as expected 4`] = ` +
+`; + +exports[`components/View prop "ref" setNativeProps method style updates as expected 5`] = ` +
+`; + +exports[`components/View prop "ref" setNativeProps method works with react-native props 1`] = ` +
+`; + exports[`components/View prop "style" value is set 1`] = `
{ expect(typeof node.measureInWindow === 'function'); expect(typeof node.setNativeProps === 'function'); }); + + describe('setNativeProps method', () => { + test('works with react-native props', () => { + const ref = React.createRef(); + const { container } = render(); + const node = ref.current; + node.setNativeProps({ + accessibilityLabel: 'label', + pointerEvents: 'box-only', + style: { + marginHorizontal: 10, + shadowColor: 'black', + shadowWidth: 2, + textAlignVertical: 'top' + } + }); + expect(container.firstChild).toMatchSnapshot(); + }); + + test('style updates as expected', () => { + const ref = React.createRef(); + const styles = StyleSheet.create({ root: { color: 'red' } }); + // initial render + const { container, rerender } = render( + + ); + const node = ref.current; + expect(container.firstChild).toMatchSnapshot(); + // set native props + node.setNativeProps({ style: { color: 'orange', height: 20, width: 20 } }); + expect(container.firstChild).toMatchSnapshot(); + // set native props again + node.setNativeProps({ style: { width: 30 } }); + expect(container.firstChild).toMatchSnapshot(); + node.setNativeProps({ style: { width: 30 } }); + node.setNativeProps({ style: { width: 30 } }); + node.setNativeProps({ style: { width: 30 } }); + expect(container.firstChild).toMatchSnapshot(); + // update render + rerender(); + expect(container.firstChild).toMatchSnapshot(); + }); + }); }); test('prop "pointerEvents"', () => {