Skip to content

Commit

Permalink
Adding a test for the "Unknown" branch when getComponentName() retu…
Browse files Browse the repository at this point in the history
…rns a falsy value. The error message in this case not the most descriptive but seems consistent with the `getComponentName(type) || 'Unknown'` pattern seen in multiple places in this code base.
  • Loading branch information
henryqdineen committed Feb 28, 2020
1 parent 74a3e77 commit 72ff92a
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -1022,4 +1022,14 @@ describe('ReactTestRenderer', () => {
expect(Scheduler).toFlushWithoutYielding();
ReactTestRenderer.create(<App />);
});

it('calling findByType() with an invalid component will fall back to "Unknown" for component name', () => {
const App = () => null;
const renderer = ReactTestRenderer.create(<App />);
const NonComponent = {};

expect(() => {
renderer.root.findByType(NonComponent);
}).toThrowError(`No instances found with node type: "Unknown"`);
});
});

0 comments on commit 72ff92a

Please sign in to comment.