blob: 85b4818d549962d8c5fced674ed652fae2520d0b [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5===================================================================
6
7Unless otherwise specified, all software contained herein is licensed
8under the Apache License, Version 2.0 (the License);
9you may not use this software except in compliance with the License.
10You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14Unless required by applicable law or agreed to in writing, software
15distributed under the License is distributed on an "AS IS" BASIS,
16WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17See the License for the specific language governing permissions and
18limitations under the License.
19
20ECOMP is a trademark and service mark of AT&T Intellectual Property.
21============LICENSE_END============================================
22*/
23
Skip Wonnell2c977e22018-03-01 08:30:15 -060024import {inject, TestBed} from '@angular/core/testing';
25import {UtilityService} from './utility.service';
26import {NotificationsService} from 'angular2-notifications';
27
28describe('UtilityService', () => {
29 beforeEach(() => {
30 TestBed.configureTestingModule({
31 providers: [UtilityService, NotificationsService]
32 });
33 });
34
35 it('should create a service...', inject([UtilityService], (service: UtilityService) => {
36 expect(service).toBeTruthy();
37 }));
38
sj108sf1e61ce2018-03-13 20:29:58 +053039 it('should generate random id', inject([UtilityService],(service: UtilityService) => {
40 let ret = service.randomId();
41
42 expect(ret).not.toBeNull();
43 }));
Skip Wonnell2c977e22018-03-01 08:30:15 -060044
45 it('should apply slashes for a string...', inject([UtilityService], (service: UtilityService) => {
sj108sf1e61ce2018-03-13 20:29:58 +053046 let text = {'vnf-host-ip-address': 'testidaddress'};
Skip Wonnell2c977e22018-03-01 08:30:15 -060047
sj108sf1e61ce2018-03-13 20:29:58 +053048 expect(service.appendSlashes(JSON.stringify(text))).toEqual('{\\"vnf-host-ip-address\\":\\"testidaddress\\"}');
Skip Wonnell2c977e22018-03-01 08:30:15 -060049 }));
50
51
52 it('should check for status 401', inject([UtilityService], (service: UtilityService) => {
53 let data = {output: {status: {code: 401}}};
54
55 expect(service.checkResult(data)).toBeFalsy();
56 }));
57
58
59 it('should check for status 400', inject([UtilityService], (service: UtilityService) => {
60 let data = {output: {status: {code: 400}}};
61
62 expect(service.checkResult(data)).toBeTruthy();
63 }));
64
65
66});