jest.mock('../../src/controller/ods-password'); import type { SpecPage } from '@stencil/core/testing'; import { newSpecPage } from '@stencil/core/testing'; import { OdsPassword } from '../../src'; describe('ods-password rendering', () => { let page: SpecPage; let root: HTMLElement | undefined; async function setup(html: string): Promise { page = await newSpecPage({ components: [OdsPassword], html, }); root = page.root; } describe('attributes', () => { 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('defaultValue', () => { it('should be reflected', async() => { const defaultValue = 'defaultValue'; await setup(``); expect(root?.getAttribute('defaultValue')).toBe(defaultValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('defaultValue')).toBeNull(); }); }); describe('hasError', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('has-error')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('has-error')).toBeNull(); }); }); describe('isClearable', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-clearable')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-clearable')).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('isMasked', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-masked')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-masked')).toBe(''); }); }); describe('isReadonly', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-readonly')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-readonly')).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('isLoading', () => { it('should be reflected', async() => { await setup(''); expect(root?.getAttribute('is-loading')).toBe(''); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('is-loading')).toBeNull(); }); }); describe('maxlength', () => { it('should be reflected', async() => { const maxlengthValue = 3; await setup(``); expect(root?.getAttribute('maxlength')).toBe(maxlengthValue.toString()); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('maxlength')).toBeNull(); }); }); describe('minlength', () => { it('should be reflected', async() => { const minlengthValue = 3; await setup(``); expect(root?.getAttribute('minlength')).toBe(minlengthValue.toString()); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('minlength')).toBeNull(); }); }); describe('name', () => { it('should be reflected', async() => { const nameValue = 'myName'; await setup(``); expect(root?.getAttribute('name')).toBe(nameValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('name')).toBeNull(); }); }); describe('pattern', () => { it('should be reflected', async() => { const patternValue = 'pattern'; await setup(``); expect(root?.getAttribute('pattern')).toBe(patternValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('pattern')).toBeNull(); }); }); describe('placeholder', () => { it('should be reflected', async() => { const placeholderValue = 'placeholder'; await setup(``); expect(root?.getAttribute('placeholder')).toBe(placeholderValue); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('placeholder')).toBeNull(); }); }); describe('value', () => { it('should be reflected', async() => { const value = 'value'; await setup(``); expect(root?.getAttribute('value')).toBe(value); }); it('should not be set by default', async() => { await setup(''); expect(root?.getAttribute('value')).toBeNull(); }); }); }); });