2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import deepFreeze from 'deep-freeze';
18 import { cloneAndSet } from '../../test-utils/Util.js';
19 import store from 'sdc-app/AppStore.js';
20 import errorResponseHandler from 'nfvo-utils/ErrorResponseHandler.js';
21 import { typeEnum as modalType } from 'nfvo-components/modal/GlobalModalConstants.js';
23 describe('Error Response Handler Util', () => {
24 beforeEach(function() {
25 deepFreeze(store.getState());
28 it('validating error in policyException', () => {
36 text: 'Error: Invalid data.'
43 const errorNotification = {
44 title: 'Error: SVC4122',
45 msg: 'Error: Invalid data.',
49 const expectedStore = cloneAndSet(
55 errorResponseHandler(xhr, textStatus, errorThrown);
57 expect(store.getState()).toEqual(expectedStore);
60 it('validating error in serviceException with variables', () => {
68 text: "Error: Invalid artifact type '%1'.",
69 variables: ['newType']
76 const errorNotification = {
77 title: 'Error: SVC4122',
78 msg: 'Error: Invalid artifact type newType.',
82 const expectedStore = cloneAndSet(
88 errorResponseHandler(xhr, textStatus, errorThrown);
90 expect(store.getState()).toEqual(expectedStore);
93 it('validating error in response', () => {
99 message: 'Error: Invalid data.'
104 const errorNotification = {
106 msg: 'Error: Invalid data.',
107 type: modalType.ERROR
110 const expectedStore = cloneAndSet(
116 errorResponseHandler(xhr, textStatus, errorThrown);
118 expect(store.getState()).toEqual(expectedStore);
121 it('validating error in request', () => {
126 responseText: 'Internal server error.'
130 const errorNotification = {
132 msg: 'Internal server error.',
133 type: modalType.ERROR
136 const expectedStore = cloneAndSet(
142 errorResponseHandler(xhr, textStatus, errorThrown);
144 expect(store.getState()).toEqual(expectedStore);