diff options
Diffstat (limited to '')
-rw-r--r-- | devtools/client/aboutdebugging/test/node/components/__snapshots__/shared-message.test.js.snap | 91 | ||||
-rw-r--r-- | devtools/client/aboutdebugging/test/node/components/shared-message.test.js | 69 |
2 files changed, 160 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/test/node/components/__snapshots__/shared-message.test.js.snap b/devtools/client/aboutdebugging/test/node/components/__snapshots__/shared-message.test.js.snap new file mode 100644 index 0000000000..eb1e3ac6ee --- /dev/null +++ b/devtools/client/aboutdebugging/test/node/components/__snapshots__/shared-message.test.js.snap @@ -0,0 +1,91 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Message component renders the expected snapshot for ERROR level 1`] = ` +<aside + className="message message--level-error qa-message some-classname-3" +> + <img + className="message__icon" + src="chrome://devtools/skin/images/aboutdebugging-error.svg" + /> + <div + className="message__body" + > + <div> + Message content + </div> + </div> +</aside> +`; + +exports[`Message component renders the expected snapshot for INFO level 1`] = ` +<aside + className="message message--level-info qa-message some-classname-1" +> + <img + className="message__icon" + src="chrome://devtools/skin/images/aboutdebugging-information.svg" + /> + <div + className="message__body" + > + <div> + Message content + </div> + </div> +</aside> +`; + +exports[`Message component renders the expected snapshot for WARNING level 1`] = ` +<aside + className="message message--level-warning qa-message some-classname-2" +> + <img + className="message__icon" + src="chrome://devtools/skin/images/alert.svg" + /> + <div + className="message__body" + > + <div> + Message content + </div> + </div> +</aside> +`; + +exports[`Message component renders with closing button renders the expected snapshot for Message with closing button 1`] = ` +<aside + className="message message--level-info qa-message some-classname-1" +> + <img + className="message__icon" + src="chrome://devtools/skin/images/aboutdebugging-information.svg" + /> + <div + className="message__body" + > + <div> + Message content + </div> + </div> + <button + className="ghost-button message__button message__button--info qa-message-button-close-button" + onClick={[Function]} + > + <Localized + attrs={ + Object { + "alt": true, + } + } + id="about-debugging-message-close-icon" + > + <img + className="qa-message-button-close-icon" + src="chrome://devtools/skin/images/close.svg" + /> + </Localized> + </button> +</aside> +`; diff --git a/devtools/client/aboutdebugging/test/node/components/shared-message.test.js b/devtools/client/aboutdebugging/test/node/components/shared-message.test.js new file mode 100644 index 0000000000..21a3f44c58 --- /dev/null +++ b/devtools/client/aboutdebugging/test/node/components/shared-message.test.js @@ -0,0 +1,69 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Unit tests for the shared/Message component. + */ + +const { shallow } = require("enzyme"); +const React = require("react"); +const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); + +const { + MESSAGE_LEVEL, +} = require("resource://devtools/client/aboutdebugging/src/constants.js"); + +const Message = React.createFactory( + require("resource://devtools/client/aboutdebugging/src/components/shared/Message.js") +); + +describe("Message component", () => { + it("renders the expected snapshot for INFO level", () => { + const message = shallow( + Message({ + children: dom.div({}, "Message content"), + className: "some-classname-1", + level: MESSAGE_LEVEL.INFO, + }) + ); + expect(message).toMatchSnapshot(); + }); + + it("renders the expected snapshot for WARNING level", () => { + const message = shallow( + Message({ + children: dom.div({}, "Message content"), + className: "some-classname-2", + level: MESSAGE_LEVEL.WARNING, + }) + ); + expect(message).toMatchSnapshot(); + }); + + it("renders the expected snapshot for ERROR level", () => { + const message = shallow( + Message({ + children: dom.div({}, "Message content"), + className: "some-classname-3", + level: MESSAGE_LEVEL.ERROR, + }) + ); + expect(message).toMatchSnapshot(); + }); +}); + +describe("Message component renders with closing button", () => { + it("renders the expected snapshot for Message with closing button", () => { + const message = shallow( + Message({ + children: dom.div({}, "Message content"), + className: "some-classname-1", + level: MESSAGE_LEVEL.INFO, + isCloseable: true, + }) + ); + expect(message).toMatchSnapshot(); + }); +}); |