Skip to content

Commit

Permalink
test(message-component): add test for message-component (#1873)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWeilian authored Jan 11, 2023
1 parent 25be9eb commit 8179a87
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/message/__tests__/message.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,28 @@ describe('Message Component test', () => {
// t-icon
expect(container.firstChild).not.toHaveClass('t-icon');
});

test(':style', () => {
const style = { backgroundColor: 'rgb(51, 51, 51)' }
THEME_LIST.forEach((t) => {
const { container } = render(<Message theme={t} style={style}>{defaultMessage}</Message>);
expect(container.firstChild).toHaveStyle(`background-color: ${style.backgroundColor};` );
});
});

test(':content as string, should get equal text', () => {
THEME_LIST.forEach((t) => {
const { container } = render(<Message theme={t} content={defaultMessage} />);
expect(container.firstChild).toHaveTextContent(defaultMessage);
});
});

test(':content as ReactNode', () => {
const ReactNode = <p className="wrapper">{defaultMessage}</p>
THEME_LIST.forEach((t) => {
const { container } = render(<Message theme={t} content={ReactNode} />);
expect(container.querySelector('.wrapper')).not.toBe(null);
expect(container.querySelector('.wrapper')).toHaveTextContent(defaultMessage);
});
});
});

0 comments on commit 8179a87

Please sign in to comment.