blob: 1b7796c21a18ed2c0d6a0efff1618d3eb55b6f70 [file] [log] [blame]
Matteo Scandolo7d539d32016-05-25 08:53:11 -07001'use strict';
2
Matteo Scandolob9fb6252016-05-26 15:09:55 -07003describe('The Subscriber View', () => {
Matteo Scandolo7d539d32016-05-25 08:53:11 -07004
Matteo Scandolob9fb6252016-05-26 15:09:55 -07005 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 Scandolo7d539d32016-05-25 08:53:11 -070015 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 Scandolob9fb6252016-05-26 15:09:55 -070023
24 httpBackend.whenGET('/api/tenant/cord/subscriber/?no_hyperlinks=1').respond(subscribersList);
Matteo Scandolo7d539d32016-05-25 08:53:11 -070025
26 scope = $rootScope.$new();
Matteo Scandolob9fb6252016-05-26 15:09:55 -070027 element = angular.element('<subscribers-list></subscribers-list>');
Matteo Scandolo7d539d32016-05-25 08:53:11 -070028 $compile(element)(scope);
29 scope.$digest();
30 isolatedScope = element.isolateScope().vm;
31 }));
32
Matteo Scandolob9fb6252016-05-26 15:09:55 -070033 it('should load 1 subscriber', () => {
34 // this
Matteo Scandolo7d539d32016-05-25 08:53:11 -070035 httpBackend.flush();
Matteo Scandolob9fb6252016-05-26 15:09:55 -070036 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 Scandolo7d539d32016-05-25 08:53:11 -070051 });
52
53});