"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const test_utilities_1 = require("../../test-utilities");
const Link_1 = require("../Link");
const Heading_1 = require("../Heading");
const ReviewItem_1 = require("./ReviewItem");
const defaultProps = {
    label: 'Contact',
    children: 'snowdevil@shopify.com',
};
describe('<ReviewItem />', () => {
    describe('label', () => {
        it('renders the label', () => {
            const label = 'Ship to';
            const reviewItem = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewItem {...defaultProps} label={label}/>);
            expect(reviewItem).toContainReactText(label);
        });
    });
    describe('children', () => {
        it('does not render a link when not provided', () => {
            const content = 'snowdevil@shopify.com';
            const reviewItem = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewItem {...defaultProps}>{content}</ReviewItem_1.ReviewItem>);
            expect(reviewItem).toContainReactText(content);
        });
    });
    it('does not render a link when `to` is not provided', () => {
        const reviewItem = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewItem label="Content">snowdevil@shopify.com</ReviewItem_1.ReviewItem>);
        expect(reviewItem).not.toContainReactComponent(Link_1.Link);
    });
    it('renders a link when `to` is provided', () => {
        const to = '/payment';
        const reviewItem = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewItem {...defaultProps} to={to}/>);
        expect(reviewItem).toContainReactComponent(Link_1.Link, {
            to,
        });
    });
    it('sets an aria-label on Link when `linkAccessibilityLabel` is provided', () => {
        const reviewItem = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewItem {...defaultProps} to="/information" linkLabel="Change" linkAccessibilityLabel="Change contact information"/>);
        expect(reviewItem).toContainReactComponent(Link_1.Link, {
            accessibilityLabel: 'Change contact information',
        });
    });
});
describe('<ReviewBlock />', () => {
    it('renders the children', () => {
        const reviewBlock = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewBlock>
        <ReviewItem_1.ReviewItem {...defaultProps} label="Ship to"/>
      </ReviewItem_1.ReviewBlock>);
        expect(reviewBlock).toContainReactComponent(ReviewItem_1.ReviewItem);
    });
    it('renders a <Heading /> when a title is passed as a prop', () => {
        const reviewBlock = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewBlock title="Review"/>);
        const heading = reviewBlock.find(Heading_1.Heading);
        expect(heading).toContainReactText('Review');
        expect(reviewBlock).toContainReactComponent('div', {
            'aria-labelledby': heading === null || heading === void 0 ? void 0 : heading.prop('id'),
        });
    });
    it('links the Heading with the section using aria-labelledBy', () => {
        const reviewBlock = test_utilities_1.mountWithContext(<ReviewItem_1.ReviewBlock title="Review" titleHidden/>);
        const heading = reviewBlock.find(Heading_1.Heading);
        expect(reviewBlock).toContainReactComponent('div', {
            'aria-labelledby': heading === null || heading === void 0 ? void 0 : heading.prop('id'),
        });
    });
});
