blob: 6005af769a391c3e45d9adf23fb0628b7cd3ab27 [file] [log] [blame]
Matteo Scandolo8cc22e42016-04-12 09:00:04 -07001'use strict';
2
3describe('The User List', () => {
4
5 var scope, element, isolatedScope, httpBackend;
6
7 beforeEach(module('xos.sampleView'));
8 beforeEach(module('templates'));
9
10 beforeEach(inject(function($httpBackend, $compile, $rootScope){
11
12 httpBackend = $httpBackend;
13 // Setting up mock request
Matteo Scandolo1dc8f3f2016-04-13 10:19:55 -070014 $httpBackend.expectGET('/api/core/users/?no_hyperlinks=1').respond([
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070015 {
16 email: 'teo@onlab.us',
17 firstname: 'Matteo',
Matteo Scandolo9e6c6fc2016-04-14 14:59:09 -070018 lastname: 'Scandolo'
Matteo Scandolo8cc22e42016-04-12 09:00:04 -070019 }
20 ]);
21
22 scope = $rootScope.$new();
23 element = angular.element('<users-list></users-list>');
24 $compile(element)(scope);
25 scope.$digest();
26 isolatedScope = element.isolateScope().vm;
27 }));
28
29 it('should load 1 users', () => {
30 httpBackend.flush();
31 expect(isolatedScope.users.length).toBe(1);
32 expect(isolatedScope.users[0].email).toEqual('teo@onlab.us');
33 expect(isolatedScope.users[0].firstname).toEqual('Matteo');
34 expect(isolatedScope.users[0].lastname).toEqual('Scandolo');
35 });
36
37});