feat(omi-cli): component template

This commit is contained in:
dntzhang 2021-08-05 18:40:48 +08:00
parent e33ceb0c71
commit 1ea7175689
3 changed files with 26 additions and 1 deletions

View File

@ -13,6 +13,11 @@
<body>
<h1>HTML Mode</h1>
<o-counter count="2"></o-counter>
<script>
document.querySelector('o-counter').addEventListener('CountChanged', function (evt) {
console.log(evt.detail)
})
</script>
</body>
</html>

View File

@ -16,13 +16,16 @@
"build": "vite build && yarn build:scss",
"build:demo": "vite build",
"build:scss": "sass src/index.scss src/index.css",
"watch": "sass --watch src/index.scss src/index.css --no-source-map"
"watch": "sass --watch src/index.scss src/index.css --no-source-map",
"test": "web-test-runner \"test/*.js\" --node-resolve"
},
"dependencies": {
"omi": "latest"
},
"devDependencies": {
"@open-wc/testing": "^2.5.33",
"@types/node": "^16.4.7",
"@web/test-runner": "^0.13.13",
"node-watch": "^0.7.1",
"sass": "^1.36.0",
"typescript": "^4.3.2",

View File

@ -0,0 +1,17 @@
import { html, fixture, expect } from '@open-wc/testing'
import '../dist/index.es.js'
describe('o-counter ', () => {
it('default prop', async () => {
const el = await fixture(html`<o-counter></o-counter>`)
expect(el.shadowRoot.innerHTML).to.equal(`<button>-</button><span>1</span><button>+</button>`)
})
it('count prop', async () => {
const el = await fixture(html`<o-counter count="2"></o-counter>`)
expect(el.shadowRoot.innerHTML).to.equal(`<button>-</button><span>2</span><button>+</button>`)
})
})