Renaming openecomp to onap
[aai/sparky-fe.git] / test / components / notificationReducer.test.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 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
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
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=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 import { expect } from 'chai';
24 import NotificationConstants from 'generic-components/notifications/NotificationConstants.js';
25 import reducer from 'generic-components/notifications/NotificationReducer.js';
26
27 describe("Notification reducer test suite", function() {
28         const initialState = {
29                 title: '',
30                 msg: '',
31                 timeout: 0
32         };
33
34         it("NOTIFY_INFO event", function() {
35                 const action = {
36                         type: NotificationConstants.NOTIFY_INFO,
37                         data: {
38                                 title: 'some title',
39                                 msg: 'some message',
40                                 timeout: 1
41                         }
42                 }
43                 const newState = reducer(initialState, action);
44
45                 expect(newState.type).to.equal('default');
46                 expect(newState.title).to.equal('some title');
47                 expect(newState.msg).to.equal('some message');
48                 expect(newState.timeout).to.equal(1);
49         });
50
51         it("NOTIFY_ERROR event", function() {
52                 const action = {
53                         type: NotificationConstants.NOTIFY_ERROR,
54                         data: {
55                                 title: 'some title',
56                                 msg: 'some message',
57                                 timeout: 1
58                         }
59                 }
60                 const newState = reducer(initialState, action);
61
62                 expect(newState.type).to.equal('error');
63                 expect(newState.title).to.equal('some title');
64                 expect(newState.msg).to.equal('some message');
65                 expect(newState.timeout).to.equal(1);
66         });
67
68         it("NOTIFY_WARNING event", function() {
69                 const action = {
70                         type: NotificationConstants.NOTIFY_WARNING,
71                         data: {
72                                 title: 'some title',
73                                 msg: 'some message',
74                                 timeout: 1
75                         }
76                 }
77                 const newState = reducer(initialState, action);
78
79                 expect(newState.type).to.equal('warning');
80                 expect(newState.title).to.equal('some title');
81                 expect(newState.msg).to.equal('some message');
82                 expect(newState.timeout).to.equal(1);
83         });
84
85         it("NOTIFY_SUCCESS event", function() {
86                 const action = {
87                         type: NotificationConstants.NOTIFY_SUCCESS,
88                         data: {
89                                 title: 'some title',
90                                 msg: 'some message',
91                                 timeout: 1
92                         }
93                 }
94                 const newState = reducer(initialState, action);
95
96                 expect(newState.type).to.equal('success');
97                 expect(newState.title).to.equal('some title');
98                 expect(newState.msg).to.equal('some message');
99                 expect(newState.timeout).to.equal(1);
100         });
101
102         it("NOTIFY_CLOSE event", function() {
103                 const action = {
104                         type: NotificationConstants.NOTIFY_CLOSE
105                 }
106                 const newState = reducer(initialState, action);
107
108                 expect(newState).to.be.null;
109         });
110 });