import { newSpecPage } from "@stencil/core/testing";
import { BpSdkNextButton } from "./bp-sdk-next-button";
const setupPage = async () => {
    return await newSpecPage({
        html: '<bp-sdk-next-button></bp-sdk-next-button>',
        components: [BpSdkNextButton],
    });
};
const setupInstance = (page) => {
    const instance = page.rootInstance;
    return instance;
};
describe('bp-sdk-next-button', () => {
    it('renders', async () => {
        const page = await setupPage();
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        page.rootInstance.navigateNext.emit = jest.fn();
        expect(element).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-next-button')).toBeFalsy();
        page.root.querySelector('bp-sdk-button').click();
        expect(page.rootInstance.navigateNext.emit).toHaveBeenCalledTimes(1);
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await setupPage();
        await page.waitForChanges();
        expect(page.root.querySelector('bp-sdk-external-next-button')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
});
