shared-message.test.js (1902B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Unit tests for the shared/Message component. 8 */ 9 10 const { shallow } = require("enzyme"); 11 const React = require("react"); 12 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 13 14 const { 15 MESSAGE_LEVEL, 16 } = require("resource://devtools/client/aboutdebugging/src/constants.js"); 17 18 const Message = React.createFactory( 19 require("resource://devtools/client/aboutdebugging/src/components/shared/Message.js") 20 ); 21 22 describe("Message component", () => { 23 it("renders the expected snapshot for INFO level", () => { 24 const message = shallow( 25 Message({ 26 children: dom.div({}, "Message content"), 27 className: "some-classname-1", 28 level: MESSAGE_LEVEL.INFO, 29 }) 30 ); 31 expect(message).toMatchSnapshot(); 32 }); 33 34 it("renders the expected snapshot for WARNING level", () => { 35 const message = shallow( 36 Message({ 37 children: dom.div({}, "Message content"), 38 className: "some-classname-2", 39 level: MESSAGE_LEVEL.WARNING, 40 }) 41 ); 42 expect(message).toMatchSnapshot(); 43 }); 44 45 it("renders the expected snapshot for ERROR level", () => { 46 const message = shallow( 47 Message({ 48 children: dom.div({}, "Message content"), 49 className: "some-classname-3", 50 level: MESSAGE_LEVEL.ERROR, 51 }) 52 ); 53 expect(message).toMatchSnapshot(); 54 }); 55 }); 56 57 describe("Message component renders with closing button", () => { 58 it("renders the expected snapshot for Message with closing button", () => { 59 const message = shallow( 60 Message({ 61 children: dom.div({}, "Message content"), 62 className: "some-classname-1", 63 level: MESSAGE_LEVEL.INFO, 64 isCloseable: true, 65 }) 66 ); 67 expect(message).toMatchSnapshot(); 68 }); 69 });