import React from 'react';
import { renderInAppContext } from '@theorchard/suite-testing';
import { TrackValidationWarningCode } from 'src/constants';
import { formatValidationMessage } from '../productValidation';

describe('formatValidationMessage', () => {
    describe('SPOTIFY_WATCHLIST_ARTIST', () => {
        test('renders artist name from product-level reason (plain string)', () => {
            const result = formatValidationMessage({
                code: TrackValidationWarningCode.SPOTIFY_WATCHLIST_ARTIST,
                reason: 'Willie Nelson',
            });
            const { container } = renderInAppContext(<>{result}</>);
            expect(container.textContent).toContain('Willie Nelson');
        });

        test('renders multiple artist names from plain string reason', () => {
            const result = formatValidationMessage({
                code: TrackValidationWarningCode.SPOTIFY_WATCHLIST_ARTIST,
                reason: 'Willie Nelson, Led Zeppelin',
            });
            const { container } = renderInAppContext(<>{result}</>);
            expect(container.textContent).toContain(
                'Willie Nelson, Led Zeppelin'
            );
        });

        test('renders bold Artist(s) In Question: label', () => {
            const result = formatValidationMessage({
                code: TrackValidationWarningCode.SPOTIFY_WATCHLIST_ARTIST,
                reason: 'Willie Nelson',
            });
            const { container } = renderInAppContext(<>{result}</>);
            expect(container.querySelector('strong')?.textContent).toContain(
                'Artist(s) In Question:'
            );
        });
    });
});
