import { render } from '@testing-library/react';
import { SuiteBadgeIconCategory } from '../types';
import { renderBadgeIcon } from '../utils';

describe('renderBadgeIcon', () => {
    test('renders flag icon', () => {
        const { container } = render(renderBadgeIcon('flag', 'no'));

        expect(container.firstChild).toHaveClass('CountryFlag', 'NO-CountryFlag');
        expect(container.firstChild?.nodeName).toEqual('IMG');
        expect(container.children).toHaveLength(1);
    });

    test('renders store icon', () => {
        const { container } = render(renderBadgeIcon('store', 'spotify'));

        expect(container.firstChild).toHaveClass('SpotifyStoreIcon');
        expect(container.firstChild?.nodeName).toEqual('IMG');
        expect(container.children).toHaveLength(1);
    });

    test('renders glyph icon', () => {
        const { container } = render(renderBadgeIcon('glyph', 'info'));

        expect(container.firstChild).toHaveClass('InfoGlyphIcon');
        expect(container.firstChild?.nodeName).toEqual('svg');
        expect(container.children).toHaveLength(1);
    });

    test('renders app icon', () => {
        const { container } = render(renderBadgeIcon('app', 'fansifter'));

        expect(container.firstChild).toHaveClass('AppIcon');
        expect(container.firstChild?.nodeName).toEqual('svg');
        expect(container.children).toHaveLength(1);
    });

    test('renders nothing if invalid category', () => {
        const { container } = render(renderBadgeIcon('wrong' as SuiteBadgeIconCategory, 'info'));

        expect(container).toBeEmptyDOMElement();
    });
});
