import { newSpecPage } from "@stencil/core/testing";
import { BpSdkNotification } from "./bp-sdk-notification";
const setupPage = async () => {
    return await newSpecPage({
        html: '<bp-sdk-notification></bp-sdk-notification>',
        components: [BpSdkNotification],
    });
};
const testNotification = { id: '123', notification: 'test', created_at: new Date() };
const setupInstance = (page) => {
    const instance = page.rootInstance;
    return instance;
};
describe('bp-sdk-notification', () => {
    it('renders', async () => {
        const page = await setupPage();
        const instance = setupInstance(page);
        instance.notification = testNotification;
        await page.waitForChanges();
        const element = page.root.querySelector('div');
        expect(element).toBeTruthy();
        expect(page.root.querySelector('bp-sdk-external-notification')).toBeFalsy();
    });
    it('renders external component if defined', async () => {
        const whenDefinedMock = jest.spyOn(customElements, 'whenDefined').mockResolvedValueOnce({});
        const page = await setupPage();
        const instance = setupInstance(page);
        instance.notification = testNotification;
        await page.waitForChanges();
        expect(page.root.querySelector('bp-sdk-external-notification')).toBeTruthy();
        whenDefinedMock.mockRestore();
    });
});
