Skip to content

Commit

Permalink
Migrate StatusBar-test to jest/renderer create abstraction in p…
Browse files Browse the repository at this point in the history
…reparation for React 19

Summary:
Use our existing thin abstraction around `react-test-renderer` `create` within `react-native/jest/renderer`, in order to benefit from the introduction of async `act` wrapping in that abstraction.

Changelog: [Internal]

Differential Revision: D58650874
  • Loading branch information
robhogan authored and facebook-github-bot committed Jun 16, 2024
1 parent 8cdf4c1 commit 8cfe52a
Showing 1 changed file with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,48 @@

'use strict';

const {create} = require('../../../../jest/renderer');
const StatusBar = require('../StatusBar');
const React = require('react');
const ReactTestRenderer = require('react-test-renderer');

describe('StatusBar', () => {
it('renders the statusbar', () => {
const component = ReactTestRenderer.create(<StatusBar />);
it('renders the statusbar', async () => {
const component = await create(<StatusBar />);
expect(component).not.toBeNull();
});
it('renders the statusbar animated enabled', () => {
const component = ReactTestRenderer.create(<StatusBar animated={true} />);
it('renders the statusbar animated enabled', async () => {
const component = await create(<StatusBar animated={true} />);
expect(component.toTree().props.animated).toBe(true);
});
it('renders the statusbar with fade transition on hide', () => {
const component = ReactTestRenderer.create(<StatusBar hidden={true} />);
it('renders the statusbar with fade transition on hide', async () => {
const component = await create(<StatusBar hidden={true} />);
expect(component.toTree().props.hidden).toBe(true);
});
it('renders the statusbar with a background color', () => {
const component = ReactTestRenderer.create(
<StatusBar backgroundColor={'#fff'} />,
);
it('renders the statusbar with a background color', async () => {
const component = await create(<StatusBar backgroundColor={'#fff'} />);
expect(component.toTree().props.backgroundColor).toBe('#fff');
expect(component.toTree().type._defaultProps.backgroundColor.animated).toBe(
false,
);
});
it('renders the statusbar with default barStyle', () => {
const component = ReactTestRenderer.create(<StatusBar />);
it('renders the statusbar with default barStyle', async () => {
const component = await create(<StatusBar />);
StatusBar.setBarStyle('default');
expect(component.toTree().type._defaultProps.barStyle.value).toBe(
'default',
);
expect(component.toTree().type._defaultProps.barStyle.animated).toBe(false);
});
it('renders the statusbar but should not be visible', () => {
const component = ReactTestRenderer.create(<StatusBar hidden={true} />);
it('renders the statusbar but should not be visible', async () => {
const component = await create(<StatusBar hidden={true} />);
expect(component.toTree().props.hidden).toBe(true);
expect(component.toTree().type._defaultProps.hidden.animated).toBe(false);
expect(component.toTree().type._defaultProps.hidden.transition).toBe(
'fade',
);
});
it('renders the statusbar with networkActivityIndicatorVisible true', () => {
const component = ReactTestRenderer.create(
it('renders the statusbar with networkActivityIndicatorVisible true', async () => {
const component = await create(
<StatusBar networkActivityIndicatorVisible={true} />,
);
expect(component.toTree().props.networkActivityIndicatorVisible).toBe(true);
Expand Down

0 comments on commit 8cfe52a

Please sign in to comment.