Skip to content

Commit 635613d

Browse files
committed
test(hx-select): surf-2024
1 parent fe9f3e3 commit 635613d

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { fixture, oneEvent, expect } from '@open-wc/testing';
2+
3+
/**
4+
* <hx-select> component tests
5+
*
6+
* @type HXSelectElement
7+
*
8+
*/
9+
describe('<hx-select> component tests', () => {
10+
const template = '<hx-select>';
11+
12+
describe('test instantiate element', () => {
13+
it('should be instantiated with hx-defined attribute', async () => {
14+
const component = /** @type {HXSelectElement} */ 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 {HXSelectElement} */ 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 {HXSelectElement} */ await fixture(template);
29+
30+
expect(component).lightDom.to.not.equal(template);
31+
});
32+
33+
});
34+
35+
describe('test Shadow DOM', () => {
36+
describe('verify render', () => {
37+
it('should have a static Shadow DOM', async function () {
38+
const component = /** @type { HXSelectElement } */ await fixture(template);
39+
const shadow = component.shadowRoot.innerHTML;
40+
41+
expect(component).shadowDom.to.equal(shadow);
42+
});
43+
44+
it('should render the Shadow Root mode open', async () => {
45+
const component = /** @type { HXSelectElement } */ await fixture(template);
46+
const mode = component.shadowRoot.mode;
47+
48+
expect(mode).to.equal('open');
49+
});
50+
});
51+
52+
describe('verify Shadow DOM markup', () => {
53+
it('markup should contain a #hxSelect <div>', async () => {
54+
const elSelector = 'div#hxSelect';
55+
const id = 'hxSelect';
56+
const component = /** @type { HXSelectElement } */ await fixture(template);
57+
const shadow = component.shadowRoot;
58+
const query = shadow.querySelector(elSelector);
59+
const queryId = query.id;
60+
61+
expect(queryId).to.equal(id);
62+
});
63+
64+
it('markup should contain a #hxTrigger <div>', async () => {
65+
const elSelector = 'div#hxSelect > #hxTrigger';
66+
const id = 'hxTrigger';
67+
const component = /** @type { HXSelectElement } */ await fixture(template);
68+
const shadow = component.shadowRoot;
69+
const query = shadow.querySelector(elSelector);
70+
const queryId = query.id;
71+
72+
expect(queryId).to.equal(id);
73+
});
74+
75+
it('markup should contain select type <hx-icon>', async () => {
76+
const elSelector = 'div#hxTrigger > hx-icon';
77+
const selectType = 'angle-down';
78+
const component = /** @type { HXSelectElement } */ await fixture(template);
79+
const shadow = component.shadowRoot;
80+
const query = shadow.querySelector(elSelector);
81+
const queryType = query.type;
82+
83+
expect(queryType).to.equal(selectType);
84+
});
85+
});
86+
});
87+
});

0 commit comments

Comments
 (0)