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 | |
Matteo Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 19 | 'use strict'; |
| 20 | |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 21 | describe('The Subscriber View', () => { |
Matteo Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 22 | |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 23 | 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 Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 33 | 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 Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 41 | |
| 42 | httpBackend.whenGET('/api/tenant/cord/subscriber/?no_hyperlinks=1').respond(subscribersList); |
Matteo Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 43 | |
| 44 | scope = $rootScope.$new(); |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 45 | element = angular.element('<subscribers-list></subscribers-list>'); |
Matteo Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 46 | $compile(element)(scope); |
| 47 | scope.$digest(); |
| 48 | isolatedScope = element.isolateScope().vm; |
| 49 | })); |
| 50 | |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 51 | it('should load 1 subscriber', () => { |
| 52 | // this |
Matteo Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 53 | httpBackend.flush(); |
Matteo Scandolo | b9fb625 | 2016-05-26 15:09:55 -0700 | [diff] [blame] | 54 | 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 Scandolo | 7d539d3 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 69 | }); |
| 70 | |
| 71 | }); |