blob: 04d1f62592cd28d234e13bff36cc8dc224294d98 [file] [log] [blame]
Matteo Scandolod2044a42017-08-07 16:08:28 -07001
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
arpiagariud4f6db12016-06-06 15:25:28 -070019'use strict';
20
21describe('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 Scandolo88b220e2016-06-17 11:57:05 -070031 httpBackend.whenGET('/api/core/sites/?no_hyperlinks=1').respond(200, []);
arpiagariud4f6db12016-06-06 15:25:28 -070032 // Setting up mock request
33 scope = $rootScope.$new();
Arpit Agarwal711b1ec2016-06-27 13:28:54 -070034 element = angular.element('<site-list></site-list>');
arpiagariud4f6db12016-06-06 15:25:28 -070035 $compile(element)(scope);
36 scope.$digest();
37 isolatedScope = element.isolateScope().vm;
38 }));
Matteo Scandolo88b220e2016-06-17 11:57:05 -070039 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 });
arpiagariud4f6db12016-06-06 15:25:28 -070074 });
arpiagariud4f6db12016-06-06 15:25:28 -070075});