summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/node/components/shared-message.test.js
blob: 02f737c20c6b11c3f89ab4bc2184b4cb25cd1999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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("devtools/client/shared/vendor/react-dom-factories");

const {
  MESSAGE_LEVEL,
} = require("devtools/client/aboutdebugging/src/constants");

const Message = React.createFactory(
  require("devtools/client/aboutdebugging/src/components/shared/Message")
);

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();
  });
});