From 80948c69a8174e29c9aa0f1eb2b01193a23a037d Mon Sep 17 00:00:00 2001 From: Lalith Kumar Karikelli Date: Mon, 10 Aug 2020 14:41:18 +0530 Subject: [PATCH] test(hx-text-control): Test cases surf2031 --- src/elements/hx-text-control/index.spec.js | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/elements/hx-text-control/index.spec.js b/src/elements/hx-text-control/index.spec.js index e69de29bb..0cc8b7b8b 100644 --- a/src/elements/hx-text-control/index.spec.js +++ b/src/elements/hx-text-control/index.spec.js @@ -0,0 +1,62 @@ +import { fixture, expect } from '@open-wc/testing'; + +/** + * component tests + * + * @type HXTextControlElement + * + */ +describe(' component tests', () => { + const template = ''; + const mockup = ` + + + + `; + + describe('instantiate element', () => { + it('should be instantiated with hx-defined attribute', async () => { + const component = /** @type {HXTextControlElement} */ await fixture(template); + const attr = component.hasAttribute('hx-defined'); + + expect(attr).to.be.true; + }); + + it('should not be hidden', async () => { + const component = /** @type {HXTextControlElement} */ 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 {HXTextControlElement} */ await fixture(template); + + expect(component).lightDom.to.not.equal(template); + }); + + it(`should NOT have a Shadow DOM`, async () => { + const component = /** @type {HXTextControlElement} */ await fixture(template); + const shadow = component.shadowRoot; + + expect(shadow).to.be.null; + }); + }); + + describe('test Control Element', () => { + it('to test control element for input type is text', async () => { + const fragment = /** @type { HXTextControlElement } */ await fixture(mockup); + const id = 'txtDemo'; + const ctrlElement = fragment.controlElement; + const ctrlElementID = ctrlElement.id; + + expect(ctrlElementID).to.equal(id); + }); + }); +});