import { newSpecPage } from "@stencil/core/testing";
import { BpSdkButton } from "./bp-sdk-button";
describe('bp-sdk-button', () => {
    it('renders', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-button></bp-sdk-button>',
            components: [BpSdkButton],
        });
        const el = page.root.querySelector('button');
        expect(el.className).toBe('bp-sdk-button');
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await newSpecPage({
            html: '<bp-sdk-button></bp-sdk-button>',
            components: [BpSdkButton],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeFalsy();
        whenDefinedMock.mockRestore();
    });
    it('renders changes to the name data', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-button text="Hello World"></bp-sdk-button>',
            components: [BpSdkButton],
        });
        let element = page.root.querySelector('button');
        expect(element.textContent).toEqual(`Hello World`);
        page.rootInstance.text = 'James';
        await page.waitForChanges();
        element = page.root.querySelector('button');
        expect(element.textContent).toEqual(`James`);
    });
});
