summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/node/components/message-icon.test.js
blob: 173bf1d383c0e23039e4edd29b244ac66887385a (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

const { MESSAGE_LEVEL } = require("devtools/client/webconsole/constants");

const expect = require("expect");
const { render } = require("enzyme");
const { createFactory } = require("devtools/client/shared/vendor/react");
const MessageIcon = createFactory(
  require("devtools/client/webconsole/components/Output/MessageIcon")
);

describe("MessageIcon component:", () => {
  it("renders icon based on level", () => {
    const rendered = render(MessageIcon({ level: MESSAGE_LEVEL.ERROR }));
    expect(rendered.hasClass("icon")).toBe(true);
    expect(rendered.attr("title")).toBe("Error");
    expect(rendered.attr("aria-live")).toBe("off");
  });

  it("renders logpoint items", () => {
    const rendered = render(
      MessageIcon({
        level: MESSAGE_LEVEL.LOG,
        type: "logPoint",
      })
    );
    expect(rendered.hasClass("logpoint")).toBe(true);
  });
});