Matteo Scandolo | d2044a4 | 2017-08-07 16:08:28 -0700 | [diff] [blame^] | 1 | |
| 2 | /* |
| 3 | * Copyright 2017-present Open Networking Foundation |
| 4 | |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
arpiagariu | d4f6db1 | 2016-06-06 15:25:28 -0700 | [diff] [blame] | 19 | 'use strict'; |
| 20 | |
| 21 | describe('Tenant View', () => { |
| 22 | |
| 23 | var scope, element, isolatedScope, httpBackend; |
| 24 | |
| 25 | beforeEach(module('xos.tenant')); |
| 26 | beforeEach(module('templates')); |
| 27 | |
| 28 | beforeEach(inject(function($httpBackend, $compile, $rootScope){ |
| 29 | |
| 30 | httpBackend = $httpBackend; |
Matteo Scandolo | 88b220e | 2016-06-17 11:57:05 -0700 | [diff] [blame] | 31 | httpBackend.whenGET('/api/core/sites/?no_hyperlinks=1').respond(200, []); |
arpiagariu | d4f6db1 | 2016-06-06 15:25:28 -0700 | [diff] [blame] | 32 | // Setting up mock request |
| 33 | scope = $rootScope.$new(); |
Arpit Agarwal | 711b1ec | 2016-06-27 13:28:54 -0700 | [diff] [blame] | 34 | element = angular.element('<site-list></site-list>'); |
arpiagariu | d4f6db1 | 2016-06-06 15:25:28 -0700 | [diff] [blame] | 35 | $compile(element)(scope); |
| 36 | scope.$digest(); |
| 37 | isolatedScope = element.isolateScope().vm; |
| 38 | })); |
Matteo Scandolo | 88b220e | 2016-06-17 11:57:05 -0700 | [diff] [blame] | 39 | describe('site list table',() =>{ |
| 40 | it('site list ', () => { |
| 41 | var sites = [ |
| 42 | { |
| 43 | 'name':'Mysite', |
| 44 | 'id':'1' |
| 45 | } |
| 46 | ]; |
| 47 | var slices = [ |
| 48 | { |
| 49 | 'site': '1', |
| 50 | 'instance_total' :1, |
| 51 | 'instance_total_ready' :1 |
| 52 | }, |
| 53 | { |
| 54 | 'site': '1', |
| 55 | 'instance_total': 2, |
| 56 | 'instance_total_ready': 3 |
| 57 | }, |
| 58 | { |
| 59 | 'site': '2', |
| 60 | 'instance_total': '1', |
| 61 | 'instance_total_ready': '2' |
| 62 | } |
| 63 | ]; |
| 64 | var result = isolatedScope.returnData(sites,slices); |
| 65 | expect(result).toEqual([ |
| 66 | { |
| 67 | 'name':'Mysite', |
| 68 | 'id':'1', |
| 69 | 'instance_total':3, |
| 70 | 'instance_total_ready':4 |
| 71 | } |
| 72 | ]); |
| 73 | }); |
arpiagariu | d4f6db1 | 2016-06-06 15:25:28 -0700 | [diff] [blame] | 74 | }); |
arpiagariu | d4f6db1 | 2016-06-06 15:25:28 -0700 | [diff] [blame] | 75 | }); |