import { type SpecPage, newSpecPage } from '@stencil/core/testing'; import { ODS_POPOVER_POSITION, ODS_POPOVER_STRATEGY, OdsPopover } from '../../src'; Object.defineProperty(global, 'CSS', { value: { escape: (value: string): string => value, }, writable: true, }); describe('ods-popover rendering', () => { let page: SpecPage; let root: HTMLElement | undefined; async function setup(html: string): Promise { page = await newSpecPage({ components: [OdsPopover], html, }); root = page.root; } beforeEach(() => { jest.spyOn(console, 'warn').mockImplementation(() => {}); }); describe('position', () => { it('should be reflected', async() => { const dummyValue = 'dummy value'; await setup(``); expect(root?.getAttribute('position')).toBe(dummyValue); }); it('should render with expected default value', async() => { await setup(''); expect(root?.getAttribute('position')).toBe(ODS_POPOVER_POSITION.top); }); }); describe('strategy', () => { it('should be reflected', async() => { const dummyValue = 'dummy value'; await setup(``); expect(root?.getAttribute('strategy')).toBe(dummyValue); }); it('should render with expected default value', async() => { await setup(''); expect(root?.getAttribute('strategy')).toBe(ODS_POPOVER_STRATEGY.absolute); }); }); describe('shadowDomTriggerId', () => { it('should be reflected', async() => { const dummyValue = 'dummy value'; await setup(``); expect(root?.getAttribute('shadow-dom-trigger-id')).toBe(dummyValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('shadow-dom-trigger-id')).toBeNull(); }); }); describe('triggerId', () => { it('should be reflected', async() => { const dummyValue = 'dummy value'; await setup(``); expect(root?.getAttribute('trigger-id')).toBe(dummyValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('trigger-id')).toBeNull(); }); }); describe('withArrow', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('with-arrow')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('with-arrow')).toBeNull(); }); }); });