/* eslint-env jest */
import React from 'react';
import { render } from 'enzyme';
import AmountPrice from './index';
import noop from 'lodash/noop';

const mockedPriceData = [
    {
        key: 'Damen Polo Organic, JAMES & NICHOLSON',
        identifier: 'precosts',
        label: 'Damen Polo Organic, JAMES & NICHOLSON',
        selectable: false,
        price: '98,00 €',
    },
    {
        key: 'Vorkosten',
        identifier: 'precosts',
        label: 'Vorkosten',
        selectable: false,
        price: '29,00 €',
    },
    {
        key: 'Werbedruck',
        identifier: 'advertisePrinting',
        label: 'Werbedruck',
        selectable: false,
        price: '42,00 €',
    },
    {
        key: 'Logokosten',
        identifier: 'logisticsCosts',
        label: 'Logokosten',
        selectable: false,
        price: '0,00 €',
    },
    {
        key: 'Korrekturanzug',
        identifier: 'proof',
        label: 'Korrekturabzug',
        selectable: true,
        price: '0,00 €',
    },
    {
        key: 'Korrekturmuster',
        identifier: 'correctionDraft',
        label: 'Korrekturmuster',
        selectable: true,
        price: '0,00 €',
    },
];

const getDefaultComponent = () => <div />;

it('renders correctly', () => {
    const tree = render(
        <AmountPrice
            width="lg"
            amount={100}
            priceFormatted="500,00 €"
            vatNotice="VAT included plus shipping"
            priceList={mockedPriceData}
            onChangeAmount={noop}
            ConfigurationModeSwitchComponent={getDefaultComponent}
        />
    );
    expect(tree).toMatchSnapshot();
});

it('renders a boxed component with the boxed prop', () => {
    const tree = render(
        <AmountPrice
            width="lg"
            amount={100}
            boxed
            priceFormatted="500,00 €"
            vatNotice="VAT included plus shipping"
            ConfigurationModeSwitchComponent={getDefaultComponent}
        />
    );
    expect(tree).toMatchSnapshot();
});

it('renders the ConfigurationModeSwitchComponent (if it is provided)', () => {
    const tree = render(
        <AmountPrice
            width="lg"
            amount={100}
            priceFormatted="500,00 €"
            vatNotice="VAT included plus shipping"
            priceList={mockedPriceData}
            onChangeAmount={noop}
            showConfigurationModeSwitch
            ConfigurationModeSwitchComponent={() => <div>Switch to Design!</div>}
        />
    );
    expect(tree).toMatchSnapshot();
});

it('renders without callToAction', () => {
    const tree = render(
        <AmountPrice
            showCallToAction={false}
            width="lg"
            amount={100}
            priceFormatted="500,00 €"
            vatNotice="VAT included plus shipping"
            priceList={mockedPriceData}
            onChangeAmount={noop}
            showConfigurationModeSwitch
            ConfigurationModeSwitchComponent={() => <div>Switch to Design!</div>}
        />
    );
    expect(tree).toMatchSnapshot();
});

it('renders receiveOfferForm', () => {
    const tree = render(
        <AmountPrice
            showReceiveOfferForm={true}
            width="lg"
            amount={100}
            priceFormatted="500,00 €"
            vatNotice="VAT included plus shipping"
            priceList={mockedPriceData}
            onChangeAmount={noop}
            showConfigurationModeSwitch
            ConfigurationModeSwitchComponent={() => <div>Switch to Design!</div>}
        />
    );
    expect(tree).toMatchSnapshot();
});
