import { newSpecPage } from "@stencil/core/testing";
import { BpSdkVehiclePanelLabel } from "./bp-sdk-vehicle-panel-label";
describe('bp-sdk-vehicle-panel-label', () => {
    const setupPage = async () => {
        return await newSpecPage({
            html: '<bp-sdk-vehicle-panel-label></bp-sdk-vehicle-panel-label>',
            components: [BpSdkVehiclePanelLabel],
        });
    };
    const getInstance = (page) => {
        return page.rootInstance;
    };
    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-label')).toBeFalsy();
    });
    it('renders a vehicle label', async () => {
        const label = '2001 FORD GORILLA';
        const page = await setupPage();
        const instance = getInstance(page);
        instance.vehicleLabel = label;
        await page.waitForChanges();
        const element = page.root.querySelector('.bp-sdk-vehicle-panel-label__container');
        expect(element.textContent).toEqual(label);
    });
    it('renders default when no label is given', async () => {
        const page = await setupPage();
        await page.waitForChanges();
        const element = page.root.querySelector('.bp-sdk-vehicle-panel-label__container');
        expect(element.textContent).toEqual('Add new vehicle');
    });
    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-label')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
});
