Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: (Container, Input, Navbar) removing get dom node #4036

Merged
merged 5 commits into from
Nov 13, 2024

Conversation

Chriscaracach
Copy link
Contributor

Why I am doing this: #3200
What I did: removing the getDOMNode and using the render in @testing-library/react

This update involves 3 component changes: Container, Input, Navbar

Copy link

codesandbox bot commented Nov 3, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Nov 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rsuite-nextjs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 1:28am
rsuite-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 1:28am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rsuite-v4 ⬜️ Ignored (Inspect) Visit Preview Nov 13, 2024 1:28am

Copy link

vercel bot commented Nov 3, 2024

@Chriscaracach is attempting to deploy a commit to the rsuite Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

codesandbox-ci bot commented Nov 3, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@@ -13,6 +13,7 @@ describe('Container styles', () => {
<span>Title</span>
</Container>
);
assert.equal(getStyle(getDOMNode(instanceRef.current), 'display'), 'flex');
const dom = instanceRef.current as Element;
assert.equal(getStyle(dom, 'display'), 'flex');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use expect instead of assert as the test assertion to maintain code style consistency.

 expect(container.firstChild).to.have.style('display', 'flex');


import '../styles/index.less';

describe('Input styles', () => {
it('Input should render the correct styles', () => {
const instanceRef = React.createRef<HTMLInputElement>();
render(<Input ref={instanceRef} />);
const dom = getDOMNode(instanceRef.current);
const dom = instanceRef.current as Element;
inChrome &&
assert.equal(getStyle(dom, 'border'), `1px solid ${toRGB('#e5e5ea')}`, 'Input border');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use expect instead of assert as the test assertion to maintain code style consistency.

@@ -10,7 +10,7 @@ describe('Navbar styles', () => {
it('Should render the correct styles', () => {
const instanceRef = React.createRef<HTMLDivElement>();
render(<Navbar ref={instanceRef} />);
const dom = getDOMNode(instanceRef.current);
const dom = instanceRef.current as Element;
assert.equal(getStyle(dom, 'backgroundColor'), toRGB('#f7f7fa'), 'NavBar background-color');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use expect instead of assert as the test assertion to maintain code style consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants