Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(hx-radio): test cases #725

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/elements/hx-radio/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { fixture, expect } from '@open-wc/testing';

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

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

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

it('should not be hidden', async () => {
const component = /** @type {HXRadioElement} */ 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 {HXRadioElement} */ 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 { HXRadioElement } */ 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 { HXRadioElement } */ await fixture(template);
const mode = component.shadowRoot.mode;

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

it('should have a single <slot>', async () => {
const component = /** @type { HXRadioElement } */ await fixture(template);
const shadow = component.shadowRoot;
const query = shadow.querySelectorAll('slot');
const len = query.length;

expect(len).to.be.equal(1);
});

it('should have an unnamed <slot>', async () => {
const component = /** @type { HXRadioElement } */ await fixture(template);
const name = component.slot;

if ( name !== null ) {
expect(name).to.be.equal('');
} else {
expect(name).to.be.null; // IE11, Legacy Edge, and older browsers
}
});
});
});
});