|
| 1 | +import { fixture, expect } from '@open-wc/testing'; |
| 2 | + |
| 3 | +/** |
| 4 | + * <hx-menuitem> component tests |
| 5 | + * |
| 6 | + * @type HXMenuitemElement |
| 7 | + * |
| 8 | + */ |
| 9 | +describe('<hx-menuitem> component tests', () => { |
| 10 | + const template = '<hx-menuitem>'; |
| 11 | + |
| 12 | + describe('instantiate element', () => { |
| 13 | + it('should be instantiated with hx-defined attribute', async () => { |
| 14 | + const component = /** @type {HXMenuitemElement} */ await fixture(template); |
| 15 | + const attr = component.hasAttribute('hx-defined'); |
| 16 | + |
| 17 | + expect(attr).to.be.true; |
| 18 | + }); |
| 19 | + |
| 20 | + it('should not be hidden', async () => { |
| 21 | + const component = /** @type {HXMenuitemElement} */ await fixture(template); |
| 22 | + const prop = component.hidden; |
| 23 | + |
| 24 | + expect(prop).to.be.false; |
| 25 | + }); |
| 26 | + |
| 27 | + it(`the rendered light DOM should NOT equal simple template ${template}`, async () => { |
| 28 | + const component = /** @type {HXMenuitemElement} */ await fixture(template); |
| 29 | + |
| 30 | + expect(component).lightDom.to.not.equal(template); |
| 31 | + }); |
| 32 | + |
| 33 | + it(`should NOT have a Shadow DOM`, async () => { |
| 34 | + const component = /** @type {HXMenuitemElement} */ await fixture(template); |
| 35 | + const shadow = component.shadowRoot; |
| 36 | + |
| 37 | + expect(shadow).to.be.null; |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + describe('test $onConnect method', () => { |
| 42 | + it('should have role attribute', async () => { |
| 43 | + const component = /** @type {HXMenuitemElement} */ await fixture(template); |
| 44 | + const attr = component.hasAttribute('role'); |
| 45 | + |
| 46 | + expect(attr).to.be.true; |
| 47 | + }); |
| 48 | + |
| 49 | + it('should have role attribute default to menuitem ', async () => { |
| 50 | + const component = /** @type {HXMenuitemElement} */ await fixture(template); |
| 51 | + const variable = 'menuitem'; |
| 52 | + const attr = component.getAttribute('role'); |
| 53 | + |
| 54 | + expect(attr).to.be.equal(variable); |
| 55 | + }); |
| 56 | + }); |
| 57 | + |
| 58 | +}); |
0 commit comments