import { type SpecPage, newSpecPage } from '@stencil/core/testing'; import { OdsSwitchItem } from '../../src'; // @ts-ignore test purpose global.MutationObserver = jest.fn(() => ({ disconnect: jest.fn(), observe: jest.fn(), })); describe('ods-switch-item rendering', () => { let page: SpecPage; let root: HTMLElement | undefined; async function setup(html: string): Promise { page = await newSpecPage({ components: [OdsSwitchItem], html, }); root = page.root; } describe('ariaLabel', () => { it('should be reflected', async() => { const ariaLabelValue = 'ariaLabel'; await setup(``); expect(root?.getAttribute('aria-label')).toBe(ariaLabelValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('aria-label')).toBeNull(); }); }); describe('ariaLabelledby', () => { it('should be reflected', async() => { const ariaLabelledbyValue = 'ariaLabelledby'; await setup(``); expect(root?.getAttribute('aria-labelledby')).toBe(ariaLabelledbyValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('aria-labelledby')).toBeNull(); }); }); describe('isChecked', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-checked')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-checked')).toBeNull(); }); }); describe('isDisabled', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-disabled')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-disabled')).toBeNull(); }); }); describe('isRequired', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-required')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-required')).toBeNull(); }); }); describe('inputId', () => { it('should be reflected', async() => { const inputIdValue = 'inputId'; await setup(``); expect(root?.getAttribute('input-id')).toBe(inputIdValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('input-id')).toBeNull(); }); }); describe('name', () => { it('should be reflected', async() => { const nameValue = 'name'; await setup(``); expect(root?.getAttribute('name')).toBe(nameValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('name')).toBeNull(); }); }); describe('value', () => { it('should be reflected', async() => { const value = 'value'; await setup(``); expect(root?.getAttribute('value')).toBe(value); }); it('should be set by default', async() => { await setup(''); expect(root?.getAttribute('value')).toBeNull(); }); }); });