-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(): mention only one user per block (#2410)
- Loading branch information
Showing
11 changed files
with
117 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 21 additions & 8 deletions
29
libs/design-system-components/src/stories/dscore/message-card.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,43 @@ | ||
import React from 'react'; | ||
import Icon from '@akashaorg/design-system-core/lib/components/Icon'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import MessageCard, { | ||
MessageCardProps, | ||
} from '@akashaorg/design-system-core/lib/components/MessageCard'; | ||
import { ExclamationTriangleIcon } from '@akashaorg/design-system-core/lib/components/Icon/hero-icons-outline'; | ||
|
||
MessageCard.displayName = 'MessageCard'; | ||
|
||
const meta: Meta<MessageCardProps> = { | ||
title: 'DSCore/Cards/MessageCard', | ||
component: MessageCard, | ||
argTypes: { | ||
title: { control: 'text' }, | ||
message: { control: 'text' }, | ||
titleIcon: { control: 'object' }, | ||
titleVariant: { control: 'text' }, | ||
elevation: { control: 'text' }, | ||
background: { control: 'text' }, | ||
borderColor: { control: 'text' }, | ||
icon: { control: 'object' }, | ||
background: { control: 'object' }, | ||
customStyle: { control: 'text' }, | ||
onClose: { action: 'card closed' }, | ||
}, | ||
}; | ||
|
||
type Story = StoryObj<MessageCardProps>; | ||
|
||
export const Default: Story = { | ||
args: { title: 'Title', elevation: '1', message: 'A sample message...' }, | ||
args: { | ||
message: 'A sample message...', | ||
}, | ||
}; | ||
|
||
export const MessageCardWithIcon: Story = { | ||
args: { | ||
icon: ( | ||
<Icon | ||
icon={<ExclamationTriangleIcon />} | ||
color={{ light: 'warningLight', dark: 'warningLight' }} | ||
/> | ||
), | ||
message: 'A sample message...', | ||
background: { light: 'warningDark/30', dark: 'warningDark/30' }, | ||
}, | ||
}; | ||
|
||
export default meta; |
45 changes: 3 additions & 42 deletions
45
libs/design-system-core/src/components/MessageCard/__tests__/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,13 @@ | ||
import * as React from 'react'; | ||
import { act, fireEvent } from '@testing-library/react'; | ||
import MessageCard from '../'; | ||
import { screen } from '@testing-library/react'; | ||
import { customRender } from '../../../test-utils'; | ||
|
||
describe('<MessageCard /> Component', () => { | ||
let componentWrapper = customRender(<></>, {}); | ||
|
||
const title = 'Title'; | ||
const message = 'Message'; | ||
|
||
const handleClose = jest.fn(); | ||
|
||
beforeEach(() => { | ||
act(() => { | ||
componentWrapper = customRender( | ||
<MessageCard title={title} message={message} elevation="1" onClose={handleClose} />, | ||
{}, | ||
); | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('renders correctly', () => { | ||
expect(componentWrapper).toBeDefined(); | ||
}); | ||
|
||
it('has correct title and message', () => { | ||
const { getByText } = componentWrapper; | ||
|
||
const titleLabel = getByText(title); | ||
const messageLabel = getByText(message); | ||
|
||
expect(titleLabel).toBeDefined(); | ||
expect(messageLabel).toBeDefined(); | ||
}); | ||
|
||
it('calls handler when clicked', () => { | ||
const { getByRole } = componentWrapper; | ||
|
||
const closeButton = getByRole('button', { name: 'close' }); | ||
expect(closeButton).toBeDefined(); | ||
expect(handleClose).toBeCalledTimes(0); | ||
|
||
fireEvent.click(closeButton); | ||
|
||
expect(handleClose).toBeCalledTimes(1); | ||
customRender(<MessageCard message={message} />, {}); | ||
expect(screen.getByText(message)).toBeInTheDocument(); | ||
}); | ||
}); |
77 changes: 20 additions & 57 deletions
77
libs/design-system-core/src/components/MessageCard/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.