UNPKG

xtal-sip

Version:

Dynamically "water" a custom element tag with the necessary dependencies to sprout the tag from an inert seedling to a thing of beauty.

53 lines (42 loc) 1.72 kB
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> <title>xtal-sip test</title> <script src="../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> <script src="../node_modules/wct-browser-legacy/browser.js"></script> <script type="module" src="../xtal-sip.js"></script> </head> <body> <test-fixture id="BasicTestFixture"> <template> <xtal-sip></xtal-sip> </template> </test-fixture> <test-fixture id="ChangedPropertyTestFixture"> <template> <xtal-sip prop1="new-prop1"></xtal-sip> </template> </test-fixture> <script type="module"> suite('xtal-sip', () => { test('instantiating the element with default properties works', () => { const element = fixture('BasicTestFixture'); assert.equal(element.prop1, 'xtal-sip'); const elementShadowRoot = element.shadowRoot; const elementHeader = elementShadowRoot.querySelector('h2'); assert.equal(elementHeader.innerHTML, 'Hello xtal-sip!'); }); test('setting a property on the element works', () => { // Create a test fixture const element = fixture('ChangedPropertyTestFixture'); assert.equal(element.prop1, 'new-prop1'); const elementShadowRoot = element.shadowRoot; const elementHeader = elementShadowRoot.querySelector('h2'); assert.equal(elementHeader.innerHTML, 'Hello new-prop1!'); }); }); </script> </body> </html>