-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Typography][joy] Convert Typography test to TypeScript #37165
Conversation
Netlify deploy previewhttps://deploy-preview-37165--material-ui.netlify.app/ Bundle size report |
import { expect } from 'chai'; | ||
import * as React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this at the top of the file as it was
import { createRenderer, describeConformance, describeJoyColorInversion } from 'test/utils'; | ||
import Typography, { typographyClasses as classes } from '@mui/joy/Typography'; | ||
import { ThemeProvider } from '@mui/joy/styles'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not change the order of imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, forgot to disable the import sorter..
@@ -40,11 +40,13 @@ describe('<Typography />', () => { | |||
|
|||
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body1', 'body2', 'body3'].forEach((level) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body1', 'body2', 'body3'].forEach((level) => { | |
(['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'body1', 'body2', 'body3'] as const).forEach((level) => { |
const classToCheck: string | RegExp = classes[level as keyof typeof classes]; | ||
expect(container.firstChild).to.have.class(classToCheck); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert the change. No error should be thrown if you address my comment above.
expect((container.firstChild?.firstChild as HTMLElement)?.tagName).to.equal('SPAN'); | ||
expect((container.firstChild?.lastChild as HTMLElement)?.tagName).to.equal('B'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect((container.firstChild?.firstChild as HTMLElement)?.tagName).to.equal('SPAN'); | |
expect((container.firstChild?.lastChild as HTMLElement)?.tagName).to.equal('B'); | |
const child = container.firstChild?.firstChild ?? null; | |
if (child === null) { | |
return; | |
} | |
expect((child as HTMLElement).tagName).to.equal('SPAN'); | |
expect((child as HTMLElement).tagName).to.equal('B'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this change would be appropiate:
The first expect
checks for the firstChild
while the second checks for the lastChild
. I'll be changing this so that I put the container.firstChild
in a value and check against null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I missed that. Yes I exactly meant what you've done :) Thanks for addressing the comment.
This PR will change the test for the
Typography
component to TypeScript with associated changes. The test is still running without issues.See #37078