import { newSpecPage } from "@stencil/core/testing";
import { BpSdkBusinessClassificationSelector } from "./bp-sdk-business-classification-selector";
describe('bp-sdk-business-classification-selector', () => {
    it('renders', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector></bp-sdk-business-classification-selector>',
            components: [BpSdkBusinessClassificationSelector],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-business-classification-selector')).toBeFalsy();
    });
    it('handles null choices', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector></bp-sdk-business-classification-selector>',
            components: [BpSdkBusinessClassificationSelector],
        });
        const instance = page.rootInstance;
        instance.showChoices = true;
        instance.choices = null;
        await page.waitForChanges();
        const element = page.root.querySelector('bp-sdk-business-classification-selector-information');
        expect(element).toBeFalsy();
    });
    it('handles choices', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector></bp-sdk-business-classification-selector>',
            components: [BpSdkBusinessClassificationSelector],
        });
        const instance = page.rootInstance;
        instance.showChoices = true;
        instance.choices = [
            {
                id: 'someChoice',
            },
        ];
        await page.waitForChanges();
        const listElement = page.root.querySelector('bp-sdk-business-classification-selector-list-container');
        expect(listElement).toBeTruthy();
    });
    it('does not display choices in read only mode', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector></bp-sdk-business-classification-selector>',
            components: [BpSdkBusinessClassificationSelector],
        });
        const instance = page.rootInstance;
        instance.showChoices = true;
        instance.choices = [
            {
                id: 'someChoice',
            },
        ];
        instance.isReadOnly = true;
        await page.waitForChanges();
        const listElement = page.root.querySelector('bp-sdk-business-classification-selector-list-container');
        expect(listElement).toBeFalsy();
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector></bp-sdk-business-classification-selector>',
            components: [BpSdkBusinessClassificationSelector],
        });
        await page.waitForChanges();
        expect(page.root.querySelector('bp-sdk-external-business-classification-selector')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
});
