2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import expect from 'expect';
22 import React from 'react';
23 import TestUtils from 'react-addons-test-utils';
24 import store from 'sdc-app/AppStore.js';
25 import ConnectedNotificationModal, {NotificationModal} from 'nfvo-components/notifications/NotificationModal.jsx';
26 import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js';
28 const title = 'test title';
29 const msg = 'test msg';
31 describe('Notification Modal Mapper and View Class: ', function () {
33 it('notification should show with type error', done => {
34 store.dispatch({type: NotificationConstants.NOTIFY_ERROR, data: {title, msg}});
36 expect(store.getState().notification).toExist();
37 expect(store.getState().notification.type).toBe('error');
42 it('notification should show with type default', done => {
43 store.dispatch({type: NotificationConstants.NOTIFY_INFO, data: {title, msg}});
45 expect(store.getState().notification).toExist();
46 expect(store.getState().notification.type).toBe('default');
51 it('notification should show with type warning', done => {
52 store.dispatch({type: NotificationConstants.NOTIFY_WARNING, data: {title, msg}});
54 expect(store.getState().notification).toExist();
55 expect(store.getState().notification.type).toBe('warning');
60 it('notification should show with type success', done => {
61 store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}});
63 expect(store.getState().notification).toExist();
64 expect(store.getState().notification.type).toBe('success');
69 it('notification should show with type success with connected component', done => {
70 store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}});
72 expect(store.getState().notification).toExist();
73 expect(store.getState().notification.type).toBe('success');
74 let renderer = TestUtils.createRenderer();
75 renderer.render(<ConnectedNotificationModal store={store}/>);
76 let renderedOutput = renderer.getRenderOutput();
77 expect(renderedOutput).toExist();
82 it('notification should hide with connected component', done => {
84 expect(store.getState().notification).toNotExist();
85 let renderer = TestUtils.createRenderer();
86 renderer.render(<ConnectedNotificationModal store={store}/>);
87 let renderedOutput = renderer.getRenderOutput();
88 expect(renderedOutput).toExist();
91 store.dispatch({type: NotificationConstants.NOTIFY_CLOSE});
94 it('notification should hide', done => {
95 store.dispatch({type: NotificationConstants.NOTIFY_CLOSE});
97 expect(store.getState().notification).toNotExist();
102 it('NotificationModal should not render', ()=> {
103 let renderer = TestUtils.createRenderer();
104 renderer.render(<NotificationModal show={false} title={title} msg={msg} type='error'/>);
105 let renderedOutput = renderer.getRenderOutput();
106 expect(renderedOutput).toExist();
109 it('NotificationModal basic default render', ()=> {
110 expect(window.document).toExist();
111 let document = TestUtils.renderIntoDocument(
112 <NotificationModal show={true} title={title} msg={msg} type='default' onCloseClick={()=>{}}/>
114 var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal primary');
115 expect(result.length).toBeGreaterThan(0);
118 it('NotificationModal basic error render', ()=> {
119 expect(window.document).toExist();
120 let document = TestUtils.renderIntoDocument(
121 <NotificationModal show={true} title={title} msg={msg} type='error' onCloseClick={()=>{}}/>
123 var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal danger');
124 expect(result.length).toBeGreaterThan(0);
127 it('NotificationModal basic warning render', ()=> {
128 expect(window.document).toExist();
129 let document = TestUtils.renderIntoDocument(
130 <NotificationModal show={true} title={title} msg={msg} type='warning' onCloseClick={()=>{}}/>
132 var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal warning');
133 expect(result.length).toBeGreaterThan(0);
136 it('NotificationModal basic success render', ()=> {
137 expect(window.document).toExist();
138 let document = TestUtils.renderIntoDocument(
139 <NotificationModal show={true} title={title} msg={msg} type='success' onCloseClick={()=>{}}/>
141 var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal success');
142 expect(result.length).toBeGreaterThan(0);