Skip to content

Commit

Permalink
test(hx-file-icon): review chnages
Browse files Browse the repository at this point in the history
  • Loading branch information
BadeJaya committed May 21, 2020
1 parent f4ede25 commit e9c0306
Showing 1 changed file with 17 additions and 35 deletions.
52 changes: 17 additions & 35 deletions src/elements/hx-file-icon/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe('<hx-file-icon> component tests', () => {
it('should have a static Shadow DOM', async function () {
const component = /** @type { HXFileIconElement } */ await fixture(template);

// FIXME: temp fix issue submitted https://github.com/open-wc/open-wc/issues/1540
const shadow = component.shadowRoot.innerHTML;

expect(component).shadowDom.to.equal(shadow);
Expand All @@ -49,26 +48,6 @@ describe('<hx-file-icon> component tests', () => {

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

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

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

it('should have an unnamed <slot>', async () => {
const component = /** @type { HXFileIconElement } */ 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
}
});
});

describe('verify Shadow DOM markup', () => {
Expand All @@ -85,13 +64,13 @@ describe('<hx-file-icon> component tests', () => {

it('markup should contain a #hxBase with an file type <hx-icon>', async () => {
const elSelector = 'div#hxFileIcon > hx-icon';
const Type = 'file';
const fileType = 'file';
const component = /** @type { HXFileIconElement } */ await fixture(template);
const shadow = component.shadowRoot;
const query = shadow.querySelector(elSelector);
const queryId = query.type;
const queryType = query.type;

expect(queryId).to.equal(Type);
expect(queryType).to.equal(fileType);
});

it('markup should contain a #hxOverlay <div>', async () => {
Expand Down Expand Up @@ -129,26 +108,29 @@ describe('<hx-file-icon> component tests', () => {
});
});

describe('test $onConnect method', () => {
it('should be type on connect', async () => {
const component = /** @type {HXFileIconElement} */ await fixture(template);
const attr = component.hasAttribute('type');

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

describe('test <hx-file-icon> getter and setter methods', () => {
it('should be able to set bell [type="bell"]', async () => {
const component = /** @type {HXFileIconElement} */ await fixture(template);
const attrType = 'bell';

component.type = attrType;
const attr = component.hasAttribute('type');
const alertType = component.getAttribute('type');
const fileType = component.getAttribute('type');

expect(attr).to.be.true;
expect(fileType).to.equal(attrType);
});

it('should be able to set extension [type="key"]', async () => {
const component = /** @type {HXFileIconElement} */ await fixture(template);
const attrType = 'key';

component.extension = attrType;
const attr = component.hasAttribute('extension');
const extensionType = component.getAttribute('extension');

expect(attr).to.be.true;
expect(alertType).to.equal(attrType);
expect(extensionType).to.equal(attrType);
});
});
});

0 comments on commit e9c0306

Please sign in to comment.