import { render } from '@testing-library/react';
import React from 'react';
import {
    MarketingHighlightStore,
    MarketingProgram,
    MarketingProgramInfoClient,
    MarketingProgramInfoEntity,
    MarketingProgramInfoScope,
    PriorityType,
} from 'shared/data/schema';
import MarketingDetails from '../marketing-details';
import type { MarketingDetailsProps } from '../marketing-details';

describe('<MarketingDetails>', () => {
    const marketingTerritories = [
        {
            category: 'Top Market',
            countryId: '1',
            name: 'United States',
        },
    ];
    const defaultProps: MarketingDetailsProps = {
        productId: '123',
        marketingPriorityState: {
            projectProductCount: 2,
            isProjectLevel: true,
            internalNote: 'internal note text',
            marketingPriority: [
                {
                    priorityId: '1',
                    priorityType: PriorityType.A,
                    territoryId: '11',
                    countryId: '11',
                    name: 'United States',
                    category: 'Top Market',
                },
            ],
            setProjectLevel: jest.fn(),
            setInternalNote: jest.fn(),
            setMarketingPriority: jest.fn(),
        },
        marketingHighlightsState: {
            projectMarketingHighlights: [
                {
                    marketingHighlight: 'global marketing highlight',
                },
                {
                    marketingHighlight: 'spotify marketing highlight',
                    store: MarketingHighlightStore.MARKETING_HIGHLIGHTS_STORE_SPOTIFY,
                },
                {
                    marketingHighlight: 'united states marketing highlight',
                    category: 'Top Market',
                    countryId: '1',
                    name: 'United States',
                },
            ],
            setProjectMarketingHighlights: jest.fn(),
        },
        marketingProgramInfosState: {
            marketingProgramInfos: [
                {
                    marketingProgramInfoId: 3291766,
                    description: 'description text',
                    client: MarketingProgramInfoClient.MARKETING_PROGRAM_INFO_OA_CLIENT,
                    marketingProgram: MarketingProgram.MARKETING_BLURB,
                    entityType:
                        MarketingProgramInfoEntity.MARKETING_PROGRAM_INFO_PRODUCT,
                    scope: MarketingProgramInfoScope.MARKETING_PROGRAM_INFO_PUBLIC_SCOPE,
                    attachment: false,
                    dateAdded: new Date(0),
                },
            ],
            setMarketingProgramInfos: jest.fn(),
        },
        marketingTerritories,
        editable: true,
        onEdit: jest.fn(),
    };

    const renderWrapper = (props: Partial<MarketingDetailsProps> = {}) =>
        render(<MarketingDetails {...defaultProps} {...props} />);

    describe('Renders component', () => {
        test('Matches snapshot', () => {
            const { container } = renderWrapper();
            expect(container).toMatchSnapshot();
        });
    });
});
