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