import { newSpecPage } from "@stencil/core/testing";
import { BpSdkDialog } from "./bp-sdk-dialog";
describe('bp-sdk-dialog', () => {
    it('renders', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-dialog></bp-sdk-dialog>',
            components: [BpSdkDialog],
        });
        await page.waitForChanges();
        expect(page.root.querySelector('dialog')).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-dialog')).toBeFalsy();
    });
    it('handles close', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-dialog></bp-sdk-dialog>',
            components: [BpSdkDialog],
        });
        const instance = page.rootInstance;
        instance.isRequired = false;
        instance.isOpen = true;
        await page.waitForChanges();
        instance.onClick();
        expect(instance.isOpen).toBeFalsy();
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await newSpecPage({
            html: '<bp-sdk-dialog></bp-sdk-dialog>',
            components: [BpSdkDialog],
        });
        await page.waitForChanges();
        expect(page.root.querySelector('dialog')).toBeFalsy();
        expect(page.root.querySelector('bp-sdk-external-dialog')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
});
