Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
xsf0105 committed Aug 20, 2024
1 parent 296259e commit 322d72b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 49 deletions.
8 changes: 0 additions & 8 deletions src/docs/rendering.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ Add a `render` method to your custom element.
```tsx
import { QuarkElement, customElement } from "quarkc"

import './my-header.js'
import './my-body.js'
import './my-footer.js'

@customElement({ tag: "quark-count" })
class Count extends QuarkElement {
render() {
return (
<>
<h1>Welcome to Quarkc!</h1>

<my-header></my-header>
<my-body></my-body>
<my-footer></my-footer>
</>
)
}
Expand Down
8 changes: 0 additions & 8 deletions src/docs/rendering.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
```tsx
import { QuarkElement, customElement } from "quarkc"

import './my-header.js'
import './my-body.js'
import './my-footer.js'

@customElement({ tag: "quark-count" })
class Count extends QuarkElement {
render() {
return (
<>
<h1>Welcome to Quarkc!</h1>

<my-header></my-header>
<my-body></my-body>
<my-footer></my-footer>
</>
)
}
Expand Down
52 changes: 35 additions & 17 deletions src/docs/testing.en-US.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Testing
## 测试

如您需要对您的组件编写单元测试,我们推荐 [@open-wc/testing](https://open-wc.org/docs/testing/testing-package/) 作为 Web components 的测试框架,`@open-wc/testing`是一个专门针对 Web components 的测试库。

Expand All @@ -25,31 +25,49 @@ class QuarkButton extends QuarkElement {

其单测用例如下:
```tsx
import { expect, fixture } from "@open-wc/testing"
import sinon from "sinon"
import "path/your-button-path"
import { expect, fixture } from "@open-wc/testing";
import "./lib/index";

const data = {
type: "primary",
}
let el
count: 0,
text: 'test'
};

describe("<your-button>", async () => {
let el;

it("type attribute", async () => {
describe("<my-component />", async () => {
it("property text exist", async () => {
el = await fixture(
`<your-button type=${data.type}>
${data.slotText}
</your-button>`
)

expect(el.type).to.equal(data.type)
`<my-component
text=${data.text}
>
</my-component>`
);
expect(el.text).to.equal(data.text);
});

})
it("property count exist", async () => {
el = await fixture(
`<my-component
count=${data.count}
>
</my-component>`
);
expect(el.count).to.equal(data.count);
});

it("property count changed", async () => {
el = await fixture(
`<my-component
count=${data.count}
>
</my-component>`
);
el.add()
expect(el.count).to.equal(data.count + 1);
});
})


```

更多使用示例,可参考[Open Web Components 官网](https://open-wc.org/docs/testing/testing-package/)
50 changes: 34 additions & 16 deletions src/docs/testing.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,49 @@ class QuarkButton extends QuarkElement {

其单测用例如下:
```tsx
import { expect, fixture } from "@open-wc/testing"
import sinon from "sinon"
import "path/your-button-path"
import { expect, fixture } from "@open-wc/testing";
import "./lib/index";

const data = {
type: "primary",
}
let el
count: 0,
text: 'test'
};

describe("<your-button>", async () => {
let el;

it("type attribute", async () => {
describe("<my-component />", async () => {
it("property text exist", async () => {
el = await fixture(
`<your-button type=${data.type}>
${data.slotText}
</your-button>`
)

expect(el.type).to.equal(data.type)
`<my-component
text=${data.text}
>
</my-component>`
);
expect(el.text).to.equal(data.text);
});

})
it("property count exist", async () => {
el = await fixture(
`<my-component
count=${data.count}
>
</my-component>`
);
expect(el.count).to.equal(data.count);
});

it("property count changed", async () => {
el = await fixture(
`<my-component
count=${data.count}
>
</my-component>`
);
el.add()
expect(el.count).to.equal(data.count + 1);
});
})


```

更多使用示例,可参考[Open Web Components 官网](https://open-wc.org/docs/testing/testing-package/)

0 comments on commit 322d72b

Please sign in to comment.