Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
Matteo Scandolo | 2aca9ab | 2016-05-26 15:09:55 -0700 | [diff] [blame^] | 3 | describe('The Subscriber View', () => { |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 4 | |
Matteo Scandolo | 2aca9ab | 2016-05-26 15:09:55 -0700 | [diff] [blame^] | 5 | const subscribersList = [ |
| 6 | { |
| 7 | humanReadableName: 'cordSubscriber-1', |
| 8 | features: {cdn: false, uplink_speed: 1000000000, downlink_speed: 1000000000, uverse: true, status: 'enabled'}, |
| 9 | id: 1, |
| 10 | identity: {account_num: '123', name: 'Stanford'}, |
| 11 | related: {} |
| 12 | } |
| 13 | ]; |
| 14 | |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 15 | var scope, element, isolatedScope, httpBackend; |
| 16 | |
| 17 | beforeEach(module('xos.subscribers')); |
| 18 | beforeEach(module('templates')); |
| 19 | |
| 20 | beforeEach(inject(function($httpBackend, $compile, $rootScope){ |
| 21 | |
| 22 | httpBackend = $httpBackend; |
Matteo Scandolo | 2aca9ab | 2016-05-26 15:09:55 -0700 | [diff] [blame^] | 23 | |
| 24 | httpBackend.whenGET('/api/tenant/cord/subscriber/?no_hyperlinks=1').respond(subscribersList); |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 25 | |
| 26 | scope = $rootScope.$new(); |
Matteo Scandolo | 2aca9ab | 2016-05-26 15:09:55 -0700 | [diff] [blame^] | 27 | element = angular.element('<subscribers-list></subscribers-list>'); |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 28 | $compile(element)(scope); |
| 29 | scope.$digest(); |
| 30 | isolatedScope = element.isolateScope().vm; |
| 31 | })); |
| 32 | |
Matteo Scandolo | 2aca9ab | 2016-05-26 15:09:55 -0700 | [diff] [blame^] | 33 | it('should load 1 subscriber', () => { |
| 34 | // this |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 35 | httpBackend.flush(); |
Matteo Scandolo | 2aca9ab | 2016-05-26 15:09:55 -0700 | [diff] [blame^] | 36 | scope.$digest(); |
| 37 | let table = $(element).find('table'); |
| 38 | let tr = table.find('tbody:last-child tr'); |
| 39 | // let tds = $(tr[1]).find('td'); |
| 40 | // console.log(tr); |
| 41 | expect(tr.length).toBe(1); |
| 42 | // expect($(tds[0]).html()).toBe('cordSubscriber-1') |
| 43 | }); |
| 44 | |
| 45 | it('should configure xos-smart-table', () => { |
| 46 | expect(isolatedScope.smartTableConfig).toEqual({resource: 'Subscribers'}); |
| 47 | }); |
| 48 | |
| 49 | it('should render xos-smart-table', () => { |
| 50 | expect($(element).find('xos-smart-table').length).toBe(1); |
Matteo Scandolo | e5be182 | 2016-05-25 08:53:11 -0700 | [diff] [blame] | 51 | }); |
| 52 | |
| 53 | }); |