Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkasany committed Jan 10, 2025
1 parent b2a45ad commit 57d6cef
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
49 changes: 49 additions & 0 deletions tests/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`dialog add rootClassName and rootStyle should render correct 1`] = `
<div
class="rc-dialog-root customize-root-class"
style="font-size: 20px;"
>
<div
class="rc-dialog-mask"
/>
<div
class="rc-dialog-wrap"
style="font-size: 10px;"
tabindex="-1"
>
<div
aria-modal="true"
class="rc-dialog"
role="dialog"
style="width: 600px; height: 903px;"
>
<div
style="outline: none;"
tabindex="0"
>
<div
class="rc-dialog-section"
>
<button
aria-label="Close"
class="rc-dialog-close"
type="button"
>
<span
class="rc-dialog-close-x"
/>
</button>
<div
class="rc-dialog-body"
/>
</div>
</div>
<div
style="width: 0px; height: 0px; overflow: hidden; outline: none;"
tabindex="0"
/>
</div>
</div>
</div>
`;

exports[`dialog add rootClassName should render correct 1`] = `
<div
class="rc-dialog-root customize-root-class"
Expand Down
4 changes: 3 additions & 1 deletion tests/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ describe('dialog', () => {
expect(wrapper.render()).toMatchSnapshot();
});

it('add rootClassName should render correct', () => {
it('add rootClassName and rootStyle should render correct', () => {
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
const wrapper = mount(
<Dialog
visible
rootClassName="customize-root-class"
rootStyle={{ fontSize: 20 }}
style={{ width: 600 }}
height={903}
wrapStyle={{ fontSize: 10 }}
Expand All @@ -56,6 +57,7 @@ describe('dialog', () => {
);
expect(wrapper.find('.customize-root-class').length).toBeTruthy();
expect(wrapper.find('.rc-dialog-wrap').props().style.fontSize).toBe(10);
expect(wrapper.find('.rc-dialog-root').props().style.fontSize).toBe(20);
expect(wrapper.find('.rc-dialog').props().style.height).toEqual(903);
expect(wrapper.find('.rc-dialog').props().style.width).toEqual(600);
});
Expand Down

0 comments on commit 57d6cef

Please sign in to comment.