blob: bf9149d8d52cbb0209b6dc7cc41f3652d1181528 [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
Matteo Scandolo7d539d32016-05-25 08:53:11 -070019'use strict';
20
Matteo Scandolob9fb6252016-05-26 15:09:55 -070021describe('The Subscriber View', () => {
Matteo Scandolo7d539d32016-05-25 08:53:11 -070022
Matteo Scandolob9fb6252016-05-26 15:09:55 -070023 const subscribersList = [
24 {
25 humanReadableName: 'cordSubscriber-1',
26 features: {cdn: false, uplink_speed: 1000000000, downlink_speed: 1000000000, uverse: true, status: 'enabled'},
27 id: 1,
28 identity: {account_num: '123', name: 'Stanford'},
29 related: {}
30 }
31 ];
32
Matteo Scandolo7d539d32016-05-25 08:53:11 -070033 var scope, element, isolatedScope, httpBackend;
34
35 beforeEach(module('xos.subscribers'));
36 beforeEach(module('templates'));
37
38 beforeEach(inject(function($httpBackend, $compile, $rootScope){
39
40 httpBackend = $httpBackend;
Matteo Scandolob9fb6252016-05-26 15:09:55 -070041
42 httpBackend.whenGET('/api/tenant/cord/subscriber/?no_hyperlinks=1').respond(subscribersList);
Matteo Scandolo7d539d32016-05-25 08:53:11 -070043
44 scope = $rootScope.$new();
Matteo Scandolob9fb6252016-05-26 15:09:55 -070045 element = angular.element('<subscribers-list></subscribers-list>');
Matteo Scandolo7d539d32016-05-25 08:53:11 -070046 $compile(element)(scope);
47 scope.$digest();
48 isolatedScope = element.isolateScope().vm;
49 }));
50
Matteo Scandolob9fb6252016-05-26 15:09:55 -070051 it('should load 1 subscriber', () => {
52 // this
Matteo Scandolo7d539d32016-05-25 08:53:11 -070053 httpBackend.flush();
Matteo Scandolob9fb6252016-05-26 15:09:55 -070054 scope.$digest();
55 let table = $(element).find('table');
56 let tr = table.find('tbody:last-child tr');
57 // let tds = $(tr[1]).find('td');
58 // console.log(tr);
59 expect(tr.length).toBe(1);
60 // expect($(tds[0]).html()).toBe('cordSubscriber-1')
61 });
62
63 it('should configure xos-smart-table', () => {
64 expect(isolatedScope.smartTableConfig).toEqual({resource: 'Subscribers'});
65 });
66
67 it('should render xos-smart-table', () => {
68 expect($(element).find('xos-smart-table').length).toBe(1);
Matteo Scandolo7d539d32016-05-25 08:53:11 -070069 });
70
71});