import { newSpecPage } from "@stencil/core/testing";
import { BpSdkBusinessClassificationSelectorRelevanceChip } from "./bp-sdk-business-classification-selector-relevance-chip";
describe('bp-sdk-business-classification-selector-relevance-chip', () => {
    it('renders', async () => {
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector-relevance-chip></bp-sdk-business-classification-selector-relevance-chip>',
            components: [BpSdkBusinessClassificationSelectorRelevanceChip],
        });
        await page.waitForChanges();
        const element = page.root.querySelector('span');
        expect(element).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-business-classification-selector-relevance-chip')).toBeFalsy();
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await newSpecPage({
            html: '<bp-sdk-business-classification-selector-relevance-chip></bp-sdk-business-classification-selector-relevance-chip>',
            components: [BpSdkBusinessClassificationSelectorRelevanceChip],
        });
        await page.waitForChanges();
        expect(page.root.querySelector('bp-sdk-external-business-classification-selector-relevance-chip')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
    describe('onConfidenceChange', () => {
        describe('high', () => {
            it('makes expected changes', async () => {
                const page = await newSpecPage({
                    html: '<bp-sdk-business-classification-selector-relevance-chip></bp-sdk-business-classification-selector-relevance-chip>',
                    components: [BpSdkBusinessClassificationSelectorRelevanceChip],
                });
                const instance = page.rootInstance;
                instance.onConfidenceChange(Number.MAX_SAFE_INTEGER);
                expect(instance.relevance).toEqual('High');
            });
        });
        describe('medium', () => {
            it('makes expected changes', async () => {
                const page = await newSpecPage({
                    html: '<bp-sdk-business-classification-selector-relevance-chip></bp-sdk-business-classification-selector-relevance-chip>',
                    components: [BpSdkBusinessClassificationSelectorRelevanceChip],
                });
                const instance = page.rootInstance;
                instance.onConfidenceChange(1);
                expect(instance.relevance).toEqual('Medium');
            });
        });
        describe('low', () => {
            it('makes expected changes', async () => {
                const page = await newSpecPage({
                    html: '<bp-sdk-business-classification-selector-relevance-chip></bp-sdk-business-classification-selector-relevance-chip>',
                    components: [BpSdkBusinessClassificationSelectorRelevanceChip],
                });
                const instance = page.rootInstance;
                instance.onConfidenceChange(0);
                expect(instance.relevance).toEqual('Low');
                instance.onConfidenceChange(Number.MIN_SAFE_INTEGER);
                expect(instance.relevance).toEqual('Low');
            });
        });
    });
});
