UNPKG

skinny-widgets

Version:

skinnable web components widgets collection

61 lines (48 loc) 2.11 kB
<!doctype html> <html> <head> <meta charset="utf-8"> <script src="../node_modules/mocha/mocha.js"></script> <script src="../node_modules/chai/chai.js"></script> <script src="../node_modules/sinon/pkg/sinon.js"></script> <script src="../node_modules/wct-mocha/wct-mocha.js"></script> </head> <body> <sk-config theme="antd" base-path="../src" lang="ru" id="skConfig" ></sk-config> <sk-tree id="skTree" link-tpl-str='<a href="?categoryId={{ id }}">{{ name }}</a>' tree-data='[{"id": 1, "name": "category1", "parentId": 0}, {"id": 2, "name": "category2", "parentId": 0}, {"id": 3, "name": "category11", "parentId": 1}, {"id": 4, "name": "category111", "parentId": 3}]'></sk-tree> <sk-tree id="skTree2" link-tpl-str='<a href="?categoryId={{ id }}">{{ name }}</a>' tree-data='[{"id": 1, "name": "category1", "parentId": 0}, {"id": 2, "name": "category2", "parentId": 0}, {"id": 3, "name": "category11", "parentId": 1}, {"id": 4, "name": "category111", "parentId": 3}]'> <template id="SkTreeTpl"> <div id="skTree2Internal">SkTree2</div> </template> </sk-tree> <script type="module"> import { whenSkRendered } from '../node_modules/sk-core/src/rd-util.js'; import { SkConfig } from '../node_modules/sk-core/src/sk-config.js'; import { SkTree } from '../node_modules/sk-tree/src/sk-tree.js'; customElements.define('sk-config', SkConfig); customElements.define('sk-tree', SkTree); suite('<sk-tree>', () => { suiteSetup(() => { }); test('is sk-tree rendered', (done) => { let element = document.getElementById('skTree'); element.whenRendered(() => { chai.assert.instanceOf(element, SkTree); done(); }); }); test('is sk-tree2 templated', (done) => { let element = document.getElementById('skTree2'); let el = element.shadowRoot.querySelector('#skTree2Internal'); chai.assert(el.innerHTML === 'SkTree2'); done(); }); }); </script> </body> </html>