Add unit tests for ref imperative methods

This commit is contained in:
Nicolas Gallagher
2020-10-08 12:27:15 -07:00
parent 583e16fa8d
commit b15e8784c4
2 changed files with 24 additions and 0 deletions
@@ -122,6 +122,18 @@ describe('components/Text', () => {
render(<Text ref={ref} />);
expect(ref).toBeCalled();
});
test('node has imperative methods', () => {
const ref = React.createRef();
act(() => {
render(<Text ref={ref} />);
});
const node = ref.current;
expect(typeof node.measure === 'function');
expect(typeof node.measureLayout === 'function');
expect(typeof node.measureInWindow === 'function');
expect(typeof node.setNativeProps === 'function');
});
});
describe('prop "selectable"', () => {
@@ -126,6 +126,18 @@ describe('components/View', () => {
render(<View ref={ref} />);
expect(ref).toBeCalled();
});
test('node has imperative methods', () => {
const ref = React.createRef();
act(() => {
render(<View ref={ref} />);
});
const node = ref.current;
expect(typeof node.measure === 'function');
expect(typeof node.measureLayout === 'function');
expect(typeof node.measureInWindow === 'function');
expect(typeof node.setNativeProps === 'function');
});
});
test('prop "pointerEvents"', () => {