From 1ea71756896c2ca8ee08576c4a0f60ce4ccdd3c0 Mon Sep 17 00:00:00 2001 From: dntzhang Date: Thu, 5 Aug 2021 18:40:48 +0800 Subject: [PATCH] feat(omi-cli): component template --- packages/omi-cli/template/component/index.html | 5 +++++ .../omi-cli/template/component/package.json | 5 ++++- .../omi-cli/template/component/test/index.js | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 packages/omi-cli/template/component/test/index.js diff --git a/packages/omi-cli/template/component/index.html b/packages/omi-cli/template/component/index.html index ac55f7324..5655ab43d 100644 --- a/packages/omi-cli/template/component/index.html +++ b/packages/omi-cli/template/component/index.html @@ -13,6 +13,11 @@

HTML Mode

+ diff --git a/packages/omi-cli/template/component/package.json b/packages/omi-cli/template/component/package.json index ca2714b9f..78b78983e 100644 --- a/packages/omi-cli/template/component/package.json +++ b/packages/omi-cli/template/component/package.json @@ -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", diff --git a/packages/omi-cli/template/component/test/index.js b/packages/omi-cli/template/component/test/index.js new file mode 100644 index 000000000..190d72ab6 --- /dev/null +++ b/packages/omi-cli/template/component/test/index.js @@ -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``) + expect(el.shadowRoot.innerHTML).to.equal(`1`) + }) + + it('count prop', async () => { + const el = await fixture(html``) + expect(el.shadowRoot.innerHTML).to.equal(`2`) + }) + +})