Skip to content

Commit

Permalink
Merge pull request #702 from BY00565233/SURF-2024
Browse files Browse the repository at this point in the history
test(hx-select): surf-2024
  • Loading branch information
100stacks authored Jun 2, 2020
2 parents fe9f3e3 + 635613d commit f4b13d8
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions src/elements/hx-select/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { fixture, oneEvent, expect } from '@open-wc/testing';

/**
* <hx-select> component tests
*
* @type HXSelectElement
*
*/
describe('<hx-select> component tests', () => {
const template = '<hx-select>';

describe('test instantiate element', () => {
it('should be instantiated with hx-defined attribute', async () => {
const component = /** @type {HXSelectElement} */ await fixture(template);
const attr = component.hasAttribute('hx-defined');

expect(attr).to.be.true;
});

it('should not be hidden', async () => {
const component = /** @type {HXSelectElement} */ await fixture(template);
const prop = component.hidden;

expect(prop).to.be.false;
});

it(`the rendered Light DOM should NOT equal simple template ${template}`, async () => {
const component = /** @type {HXSelectElement} */ await fixture(template);

expect(component).lightDom.to.not.equal(template);
});

});

describe('test Shadow DOM', () => {
describe('verify render', () => {
it('should have a static Shadow DOM', async function () {
const component = /** @type { HXSelectElement } */ await fixture(template);
const shadow = component.shadowRoot.innerHTML;

expect(component).shadowDom.to.equal(shadow);
});

it('should render the Shadow Root mode open', async () => {
const component = /** @type { HXSelectElement } */ await fixture(template);
const mode = component.shadowRoot.mode;

expect(mode).to.equal('open');
});
});

describe('verify Shadow DOM markup', () => {
it('markup should contain a #hxSelect <div>', async () => {
const elSelector = 'div#hxSelect';
const id = 'hxSelect';
const component = /** @type { HXSelectElement } */ await fixture(template);
const shadow = component.shadowRoot;
const query = shadow.querySelector(elSelector);
const queryId = query.id;

expect(queryId).to.equal(id);
});

it('markup should contain a #hxTrigger <div>', async () => {
const elSelector = 'div#hxSelect > #hxTrigger';
const id = 'hxTrigger';
const component = /** @type { HXSelectElement } */ await fixture(template);
const shadow = component.shadowRoot;
const query = shadow.querySelector(elSelector);
const queryId = query.id;

expect(queryId).to.equal(id);
});

it('markup should contain select type <hx-icon>', async () => {
const elSelector = 'div#hxTrigger > hx-icon';
const selectType = 'angle-down';
const component = /** @type { HXSelectElement } */ await fixture(template);
const shadow = component.shadowRoot;
const query = shadow.querySelector(elSelector);
const queryType = query.type;

expect(queryType).to.equal(selectType);
});
});
});
});

0 comments on commit f4b13d8

Please sign in to comment.