Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
| 5 | =================================================================== |
| 6 | |
| 7 | Unless otherwise specified, all software contained herein is licensed |
| 8 | under the Apache License, Version 2.0 (the License); |
| 9 | you may not use this software 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 | |
| 20 | ECOMP is a trademark and service mark of AT&T Intellectual Property. |
| 21 | ============LICENSE_END============================================ |
| 22 | */ |
| 23 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 24 | import {inject, TestBed} from '@angular/core/testing'; |
| 25 | import {UtilityService} from './utility.service'; |
| 26 | import {NotificationsService} from 'angular2-notifications'; |
| 27 | |
| 28 | describe('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 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame^] | 39 | it('should generate random id', inject([UtilityService],(service: UtilityService) => { |
| 40 | let ret = service.randomId(); |
| 41 | |
| 42 | expect(ret).not.toBeNull(); |
| 43 | })); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 44 | |
| 45 | it('should apply slashes for a string...', inject([UtilityService], (service: UtilityService) => { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame^] | 46 | let text = {'vnf-host-ip-address': 'testidaddress'}; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 47 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame^] | 48 | expect(service.appendSlashes(JSON.stringify(text))).toEqual('{\\"vnf-host-ip-address\\":\\"testidaddress\\"}'); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 49 | })); |
| 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 | }); |