Skip to content

Commit 4863d93

Browse files
authored
Merge pull request #700 from BY00565233/SURF-2021
test(hx-search): surf-2021
2 parents f4b13d8 + f14dc60 commit 4863d93

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { fixture, expect } from '@open-wc/testing';
2+
3+
/**
4+
* <hx-search> component tests
5+
*
6+
* @type HXSearchElement
7+
*
8+
*/
9+
describe('<hx-search> component tests', () => {
10+
const template = '<hx-search>';
11+
12+
describe('test instantiate element', () => {
13+
it('should be instantiated with hx-defined attribute', async () => {
14+
const component = /** @type {HXSearchElement} */ 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 {HXSearchElement} */ 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 {HXSearchElement} */ 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 { HXSearchElement } */ 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 { HXSearchElement } */ 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 #hxSearch <div>', async () => {
54+
const elSelector = 'div#hxSearch';
55+
const id = 'hxSearch';
56+
const component = /** @type { HXSearchElement } */ 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 #hxIcon with search type <hx-icon>', async () => {
65+
const elSelector = 'div#hxSearch > hx-icon';
66+
const searchType = 'search';
67+
const component = /** @type { HXSearchElement } */ await fixture(template);
68+
const shadow = component.shadowRoot;
69+
const query = shadow.querySelector(elSelector);
70+
const queryType = query.type;
71+
72+
expect(queryType).to.equal(searchType);
73+
});
74+
});
75+
});
76+
});

0 commit comments

Comments
 (0)