From 8179a87ba34224b8b424aaf1cebee6601fd3a086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=95=E6=9F=8F=E7=84=B6?= <993967177@qq.com> Date: Wed, 11 Jan 2023 10:59:36 +0800 Subject: [PATCH] test(message-component): add test for message-component (#1873) (#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); + }); + }); });