Skip to content

Commit

Permalink
test(message-component): add test for message-component
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWeilian committed Jan 10, 2023
1 parent 26b23a8 commit 5a44cab
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 or 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 5a44cab

Please sign in to comment.