import { newSpecPage } from "@stencil/core/testing";
import { BpSdkAddItemContainer } from "./bp-sdk-add-item-container";
describe('bp-sdk-add-item-container', () => {
    it('renders', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-add-item-container></bp-sdk-add-item-container>',
            components: [BpSdkAddItemContainer],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeTruthy();
    });
    it('help-text', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-add-item-container></bp-sdk-add-item-container>',
            components: [BpSdkAddItemContainer],
        });
        const instance = page.rootInstance;
        instance.helpText = 'help text';
        await page.waitForChanges();
        const element = page.root.querySelector('.bp-sdk-add-item__help-text');
        expect(element.textContent).toBe(instance.helpText);
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await newSpecPage({
            html: '<bp-sdk-add-item-container></bp-sdk-add-item-container>',
            components: [BpSdkAddItemContainer],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeFalsy();
        whenDefinedMock.mockRestore();
    });
    describe('handleClick', () => {
        it('makes expected calls', async () => {
            const page = await newSpecPage({
                html: '<bp-sdk-add-item-container></bp-sdk-add-item-container>',
                components: [BpSdkAddItemContainer],
            });
            await page.waitForChanges();
            const instance = page.rootInstance;
            instance.addItem.emit = jest.fn();
            instance.handleClick();
            expect(instance.addItem.emit).toHaveBeenCalledTimes(1);
        });
    });
});
