Skip to content

Commit

Permalink
test: 完善 Select 组件测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
yyz945947732 committed Aug 29, 2023
1 parent 78f2b99 commit f645d98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/stories/为什么使用.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### 为什么使用

- #### 完善的单元测试
权限组件与工具函数都编写了丰富的测试用例
权限组件与工具函数都编写了完善的测试用例
- #### 提供强大的二次封装能力

如果目前的权限组件无法满足你的需求,或者你希望你的权限组件是基于其他组件库,这些场景你都可以基于基础权限组件 `Wrapper` 等或工具方法 `useAuthData` 来轻易的封装你的权限组件。
Expand Down
19 changes: 11 additions & 8 deletions src/test/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ const authConfig = {
"select.option1": true,
"select.option1_1": true,
"select.option1_3": true,
"select.option2": true,
"select.option2_1": true,
"select.option4": true,
};

function SelectExample({ dataSource }: SelectProps) {
return (
<Auth.Provider auth={authConfig}>
<Auth.Select dataSource={dataSource} />
<Auth.Select visible dataSource={dataSource} />
</Auth.Provider>
);
}

describe("Auth.Select", () => {
test("Check if Select render success", () => {
test("Check if Select.Option should not render without auth", () => {
const { container } = render(
<SelectExample
dataSource={[
Expand All @@ -47,9 +44,15 @@ describe("Auth.Select", () => {
],
},
]}
/>
/>,
{
baseElement: document.documentElement,
}
);
const html = container.innerHTML;
expect(html).toContain("请选择");
const html = container.ownerDocument.documentElement.innerHTML;
expect(html).toContain("我是根结点1号");
expect(html).toContain("我是子节点1_1号");
expect(html).not.toContain("我是子节点1_2号");
expect(html).toContain("我是子节点1_3号");
});
});

0 comments on commit f645d98

Please sign in to comment.