import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import { testId } from '../Panel/Panel';
import { AppBar, Text } from '../..';
describe('', () => {
it('should render children', () => {
const { getByTestId } = render(
This is an AppBar
,
);
expect(getByTestId(testId)).toHaveTextContent('This is an AppBar');
});
it('should render custom styles', () => {
const style = { marginTop: 42 };
const { getByTestId } = render(
This is an AppBar
,
);
expect(getByTestId(testId)).toHaveStyle(style);
});
});
describe('', () => {
it('should render custom styles', () => {
const style = { marginTop: 42 };
const { getByTestId } = render(
,
);
expect(getByTestId('content')).toHaveStyle(style);
});
describe('title', () => {
it('should render title', () => {
const { getByText } = render(
,
);
expect(getByText('Title')).toBeTruthy();
});
it('should pass styles to title', () => {
const style = { color: 'red' };
const { getByText } = render(
,
);
expect(getByText('Title')).toHaveStyle(style);
});
});
describe('subtitle', () => {
it('should render subtitle', () => {
const { getByText } = render(
,
);
expect(getByText('Subtitle')).toBeTruthy();
});
it('should pass styles to subtitle', () => {
const style = { color: 'red' };
const { getByText } = render(
,
);
expect(getByText('Subtitle')).toHaveStyle(style);
});
});
describe('prop: onPress', () => {
it('should handle onPress', () => {
const onPress = jest.fn();
const { getByTestId } = render(
,
);
fireEvent(getByTestId('content'), 'press');
expect(onPress).toHaveBeenCalled();
});
});
});
describe('', () => {
it('should render custom styles', () => {
const style = { marginTop: 42 };
const { getByTestId } = render(
,
);
expect(getByTestId('backAction')).toHaveStyle(style);
});
describe('prop: onPress', () => {
it('should handle onPress', () => {
const onPress = jest.fn();
const { getByTestId } = render(
,
);
fireEvent(getByTestId('backAction'), 'press');
expect(onPress).toHaveBeenCalled();
});
});
});