From 5e10d471beeab587aee63856a74f75050a9eb161 Mon Sep 17 00:00:00 2001 From: Boran <993967177@qq.com> Date: Tue, 10 Jan 2023 20:34:41 +0800 Subject: [PATCH] test(message-component): add test for message-component (#1280) --- src/message/__tests__/message.test.jsx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/message/__tests__/message.test.jsx b/src/message/__tests__/message.test.jsx index c572f68335..59e217d14d 100644 --- a/src/message/__tests__/message.test.jsx +++ b/src/message/__tests__/message.test.jsx @@ -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({defaultMessage}); + expect(container.firstChild).toHaveStyle(`background-color: ${style.backgroundColor};` ); + }); + }); + + test(':content as string, should get equal text', () => { + THEME_LIST.forEach((t) => { + const { container } = render(); + expect(container.firstChild).toHaveTextContent(defaultMessage); + }); + }); + + test(':content as ReactNode', () => { + const ReactNode =

{defaultMessage}

+ THEME_LIST.forEach((t) => { + const { container } = render(); + expect(container.querySelector('.wrapper')).not.toBe(null); + expect(container.querySelector('.wrapper')).toHaveTextContent(defaultMessage); + }); + }); });