import { newSpecPage } from "@stencil/core/testing";
import { BpSdkFooter } from "./bp-sdk-footer";
const setupPage = async () => {
    return await newSpecPage({
        html: '<bp-sdk-footer></bp-sdk-footer>',
        components: [BpSdkFooter],
    });
};
const setupInstance = (page) => {
    const instance = page.rootInstance;
    instance.darkMode = false;
    return instance;
};
describe('bp-sdk-footer', () => {
    it('renders', async () => {
        const page = await setupPage();
        await page.waitForChanges();
        const element = page.root.querySelector('footer');
        expect(element).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-footer')).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-footer')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
    describe('darkMode', () => {
        it('renders light mode logo', async () => {
            const page = await setupPage();
            setupInstance(page);
            await page.waitForChanges();
            const element = page.root.querySelector('img');
            expect(element.getAttribute('src')).toEqual('light-mode-logo.svg');
        });
        it('renders dark mode logo', async () => {
            const page = await setupPage();
            const instance = setupInstance(page);
            instance.darkMode = true;
            await page.waitForChanges();
            const element = page.root.querySelector('img');
            expect(element.getAttribute('src')).toEqual('dark-mode-logo.svg');
        });
    });
});
