import { newSpecPage } from "@stencil/core/testing";
import { BpSdkVehicleVin } from "./bp-sdk-vehicle-vin";
describe('bp-sdk-vehicle-vin', () => {
    it('renders', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-vehicle-vin></bp-sdk-vehicle-vin>',
            components: [BpSdkVehicleVin],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeTruthy();
    });
    it('renders configurations select', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-vehicle-vin></bp-sdk-vehicle-vin>',
            components: [BpSdkVehicleVin],
        });
        const instance = page.rootInstance;
        instance.shouldSelectConfiguration = true;
        await page.waitForChanges();
        const element = page.root.querySelector('bp-sdk-vehicle-configurations-container');
        expect(element).toBeTruthy();
    });
    it('passes question group ID to configurations container', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-vehicle-vin></bp-sdk-vehicle-vin>',
            components: [BpSdkVehicleVin],
        });
        const instance = page.rootInstance;
        instance.questionGroupId = 'testQuestionGroupId';
        instance.shouldSelectConfiguration = true;
        await page.waitForChanges();
        const element = page.root.querySelector('bp-sdk-vehicle-configurations-container');
        expect(element.getAttribute('questionGroupId')).toEqual(instance.questionGroupId);
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await newSpecPage({
            html: '<bp-sdk-vehicle-vin></bp-sdk-vehicle-vin>',
            components: [BpSdkVehicleVin],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeFalsy();
        whenDefinedMock.mockRestore();
    });
});
