Use proper casing for alert type text
This commit is contained in:
@@ -42,6 +42,15 @@ const getBorderColor = ({ type }: ContainerProps): string => {
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeText = (type: ContainerProps['type']): string => {
|
||||
switch (type) {
|
||||
case 'warning':
|
||||
return 'Warning';
|
||||
case 'error':
|
||||
return 'Error';
|
||||
}
|
||||
};
|
||||
|
||||
const Container = styled.div<ContainerProps>`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -81,7 +90,7 @@ type Props = {
|
||||
export const Alert = ({ type, title, message, actions, inverse }: Props) => {
|
||||
return (
|
||||
<Container type={type} inverse={inverse}>
|
||||
<Title>{type}: {title}</Title>
|
||||
<Title>{getTypeText(type)}: {title}</Title>
|
||||
<span>{message}</span>
|
||||
{actions && <ActionsContainer>{actions}</ActionsContainer>}
|
||||
</Container>
|
||||
|
||||
@@ -6,14 +6,14 @@ describe(Alert.name, () => {
|
||||
it('renders a warning correctly', () => {
|
||||
render(<Alert type="warning" title="Warning title" message="Warning content" />);
|
||||
|
||||
expect(screen.getByText('warning: Warning title')).toBeInTheDocument();
|
||||
expect(screen.getByText('Warning: Warning title')).toBeInTheDocument();
|
||||
expect(screen.getByText('Warning content')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders an error correctly', () => {
|
||||
render(<Alert type="error" title="Error title" message="Error content" />);
|
||||
|
||||
expect(screen.getByText('error: Error title')).toBeInTheDocument();
|
||||
expect(screen.getByText('Error: Error title')).toBeInTheDocument();
|
||||
expect(screen.getByText('Error content')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user