/** *******************************************************************************************************************
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License").
You may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. *
******************************************************************************************************************** */
import React from 'react';
import { render } from '@testing-library/react';
import Container from '.';
import Text from '../../components/Text';
import Button from '../../components/Button';
describe('Container', () => {
const title = 'Title';
const bodyText = 'Body';
const subtitle = 'subtitle';
const buttonText = 'Action Button';
it('renders a container with title', () => {
const { getByText } = render(
{bodyText}
);
expect(getByText(title)).toBeInTheDocument();
expect(getByText(bodyText)).toBeInTheDocument();
});
it('renders a container with subtitle', () => {
const { getByText } = render(
{bodyText}
);
expect(getByText(subtitle)).toBeInTheDocument();
});
it('renders a container with subtitle being arbitrary react', () => {
const { getByText } = render(
{subtitle}}>
{bodyText}
);
expect(getByText(subtitle)).toBeInTheDocument();
});
it('renders a container with footer', () => {
const footer = 'Footer';
const { getByText } = render(
BodyText
);
expect(getByText(footer)).toBeInTheDocument();
});
it('can be accessed by custom test-id', () => {
const { getByTestId } = render(
{bodyText}
);
expect(getByTestId('container-1')).toBeInTheDocument();
});
describe('headerContent', () => {
const header = 'Header';
it('only renders for container with title', () => {
const { getByText } = render(
BodyText
);
expect(getByText(header)).toBeInTheDocument();
});
it('only renders for container with subtitle', () => {
const { getByText } = render(
BodyText
);
expect(getByText(header)).toBeInTheDocument();
});
it('only renders for container with actionGroup', () => {
const { getByText } = render(
{buttonText}} headerContent={header}>
BodyText
);
expect(getByText(header)).toBeInTheDocument();
});
it('only renders for container with headerContent', () => {
const { queryByText } = render(
BodyText
);
expect(queryByText(header)).toBeInTheDocument();
});
});
describe('actionGroup', () => {
it('only renders for container with title', () => {
const { getByText } = render(
{buttonText}}>
BodyText
);
expect(getByText(buttonText)).toBeInTheDocument();
});
it('only renders for container with subtitle', () => {
const { getByText } = render(
{buttonText}}>
BodyText
);
expect(getByText(buttonText)).toBeInTheDocument();
});
it('does not render for container without title or subtitle', () => {
const { queryByText } = render(
{buttonText}}>
BodyText
);
expect(queryByText(buttonText)).toBeInTheDocument();
});
});
});