2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 import { expect } from 'chai';
22 import React from 'react';
23 import TestUtils from 'react-dom/test-utils';
24 import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx';
25 import InlineMessageConstants from 'generic-components/InlineMessage/InlineMessageConstants.js';
27 describe('Core Inline Message Suite', function() {
34 beforeEach(function() {
35 _warningMessage = TestUtils.renderIntoDocument(<InlineMessage level='warning' messageTxt='Warning Message' />);
36 _successMessage = TestUtils.renderIntoDocument(<InlineMessage level='success' messageTxt='Success Message' />);
37 _dangerMessage = TestUtils.renderIntoDocument(<InlineMessage level='danger' messageTxt='Danger Message' />);
38 _defaultMessage = TestUtils.renderIntoDocument(<InlineMessage level='info' messageTxt='Info Message' />);
42 it('Inline Message - validate success message panel', function() {
43 let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_successMessage, 'alert');
44 expect(alertPanel).to.exist; // alert panel exists
45 let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_successMessage, 'alert-success');
46 expect(alertPanel_style).to.exist; // alert panel has proper styling
47 let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_successMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
48 expect(messagePanel).to.exist;
49 expect(messagePanel.innerHTML).to.have.string('Success Message'); // messagePanel panel has proper message
50 let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_successMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
51 expect(iconPanel).to.exist;
52 expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.SUCCESS_CLASSNAME); // notification panel has proper styling
54 it('Inline Message - validate info message panel', function() {
55 let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, 'alert');
56 expect(alertPanel).to.exist; // alert panel exists
57 let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, 'alert-info');
58 expect(alertPanel_style).to.exist; // alert panel has proper styling
59 let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
60 expect(messagePanel).to.exist;
61 expect(messagePanel.innerHTML).to.have.string('Info Message'); // messagePanel panel has proper message
62 let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
63 expect(iconPanel).to.exist;
64 expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.DEFAULT_CLASSNAME); // icon panel has proper styling
66 it('Inline Message - validate warning message panel', function() {
67 let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, 'alert');
68 expect(alertPanel).to.exist; // alert panel exists
69 let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, 'alert-warning');
70 expect(alertPanel_style).to.exist; // alert panel has proper styling
71 let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
72 expect(messagePanel).to.exist;
73 expect(messagePanel.innerHTML).to.have.string('Warning Message'); // messagePanel panel has proper message
74 let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
75 expect(iconPanel).to.exist;
76 expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.WARNING_CLASSNAME); // icon panel has proper styling
78 it('Inline Message - validate danger message panel', function() {
79 let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, 'alert');
80 expect(alertPanel).to.exist; // alert panel exists
81 let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, 'alert-danger');
82 expect(alertPanel_style).to.exist; // alert panel has proper styling
83 let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
84 expect(messagePanel).to.exist;
85 expect(messagePanel.innerHTML).to.have.string('Danger Message'); // messagePanel panel has proper message
86 let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
87 expect(iconPanel).to.exist;
88 expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.DANGER_CLASSNAME); // icon panel has proper styling