summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/node/components/shared-message.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/aboutdebugging/test/node/components/shared-message.test.js')
-rw-r--r--devtools/client/aboutdebugging/test/node/components/shared-message.test.js69
1 files changed, 69 insertions, 0 deletions
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();
+ });
+});