import { newSpecPage } from "@stencil/core/testing";
import { BpSdkVehiclePanelButtons } from "./bp-sdk-vehicle-panel-buttons";
const setupPage = async () => {
    return await newSpecPage({
        html: '<bp-sdk-vehicle-panel-buttons></bp-sdk-vehicle-panel-buttons>',
        components: [BpSdkVehiclePanelButtons],
    });
};
const setupInstance = (page) => {
    return page.rootInstance;
};
describe('bp-sdk-vehicle-panel-buttons', () => {
    it('renders', async () => {
        const page = await setupPage();
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-vehicle-panel-buttons')).toBeFalsy();
    });
    it('handles canEdit state', async () => {
        const page = await setupPage();
        const instance = setupInstance(page);
        instance.canEdit = true;
        await page.waitForChanges();
        const element = page.root.querySelector('bp-sdk-vehicle-edit-button');
        expect(element).toBeTruthy();
    });
    it('handles canDelete state', async () => {
        const page = await setupPage();
        const instance = setupInstance(page);
        instance.canDelete = true;
        instance.canEdit = true;
        await page.waitForChanges();
        const element = page.root.querySelector('bp-sdk-vehicle-delete-button');
        expect(element).toBeTruthy();
    });
    it("can't delete if you can't edit", async () => {
        const page = await setupPage();
        const instance = setupInstance(page);
        instance.canDelete = true;
        instance.canEdit = false;
        await page.waitForChanges();
        const element = page.root.querySelector('bp-sdk-vehicle-delete-button');
        expect(element).toBeFalsy();
    });
    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-vehicle-panel-buttons')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
});
