Skip to content

Commit c5fb371

Browse files
rubennortefacebook-github-bot
authored andcommitted
Add test for View refs (#52982)
Summary: Pull Request resolved: #52982 Changelog: [internal] Just adding a few tests for `View` refs, to show as an example of what a test for a public component should have. Reviewed By: rshest Differential Revision: D79447449 fbshipit-source-id: 75b9dbb45824d927bcf63472da25c7c5a52c7eb6
1 parent 68e5a24 commit c5fb371

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

  • packages/react-native/Libraries/Components/View/__tests__

packages/react-native/Libraries/Components/View/__tests__/View-itest.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,31 @@ describe('<View>', () => {
491491
});
492492
});
493493
});
494+
495+
describe('ref', () => {
496+
it('is an element node', () => {
497+
const elementRef = createRef<HostInstance>();
498+
499+
const root = Fantom.createRoot();
500+
501+
Fantom.runTask(() => {
502+
root.render(<View ref={elementRef} />);
503+
});
504+
505+
expect(elementRef.current).toBeInstanceOf(ReactNativeElement);
506+
});
507+
508+
it('uses the "RN:View" tag name', () => {
509+
const elementRef = createRef<HostInstance>();
510+
511+
const root = Fantom.createRoot();
512+
513+
Fantom.runTask(() => {
514+
root.render(<View ref={elementRef} />);
515+
});
516+
517+
const element = ensureInstance(elementRef.current, ReactNativeElement);
518+
expect(element.tagName).toBe('RN:View');
519+
});
520+
});
494521
});

0 commit comments

Comments
 (0)