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
[Chip] Add chip classes #33801
[Chip] Add chip classes #33801
Conversation
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 add a test for this please.
it('should render with the root and the info class', () => { | ||
const { container } = render(<Chip color="info" />); | ||
|
||
const chip = container.querySelector(`.${classes.root}`); | ||
expect(chip).to.have.class(classes.colorInfo); | ||
}); | ||
|
||
it('should render with the root and the error class', () => { | ||
const { container } = render(<Chip color="error" />); | ||
|
||
const chip = container.querySelector(`.${classes.root}`); | ||
expect(chip).to.have.class(classes.colorError); | ||
}); | ||
|
||
it('should render with the root and the warning class', () => { | ||
const { container } = render(<Chip color="warning" />); | ||
|
||
const chip = container.querySelector(`.${classes.root}`); | ||
expect(chip).to.have.class(classes.colorWarning); | ||
}); | ||
|
||
it('should render with the root and the success class', () => { | ||
const { container } = render(<Chip color="success" />); | ||
|
||
const chip = container.querySelector(`.${classes.root}`); | ||
expect(chip).to.have.class(classes.colorSuccess); | ||
}); |
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.
it('should render with the root and the info class', () => { | |
const { container } = render(<Chip color="info" />); | |
const chip = container.querySelector(`.${classes.root}`); | |
expect(chip).to.have.class(classes.colorInfo); | |
}); | |
it('should render with the root and the error class', () => { | |
const { container } = render(<Chip color="error" />); | |
const chip = container.querySelector(`.${classes.root}`); | |
expect(chip).to.have.class(classes.colorError); | |
}); | |
it('should render with the root and the warning class', () => { | |
const { container } = render(<Chip color="warning" />); | |
const chip = container.querySelector(`.${classes.root}`); | |
expect(chip).to.have.class(classes.colorWarning); | |
}); | |
it('should render with the root and the success class', () => { | |
const { container } = render(<Chip color="success" />); | |
const chip = container.querySelector(`.${classes.root}`); | |
expect(chip).to.have.class(classes.colorSuccess); | |
}); | |
it('should render with the color class name based on the color prop', () => { | |
const capitalize = str => str.charAt(0).toUpperCase() + str.slice(1); | |
['error', 'success', 'info', 'warning'].map((color) => { | |
const { container } = render(<Chip color={color} />); | |
const chip = container.querySelector(`.${classes.root}`); | |
expect(chip).to.have.class(classes[`color${capitalize(color)}`]); | |
}); |
Can we simplify maybe to something like this (I haven't run, there could be some issues with the code :))
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.
Yes, Thanks for the suggestion. I have updated the unit tests for color classes.
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.
Looks good, left one final comment.
PTAL, Thanks! |
Hi @mnajdova, any updates on this? |
Hey @mnajdova, any updates on this? |
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.
Looks good, thanks for the contribution. Sorry for the delay
I have tested this fix locally and also tested using a preview package on CodeSandbox.
Fixes #33246