blob: b00fa5e4ee250ad4962dcbea7463a12ac2d62675 [file] [log] [blame]
Matteo Scandolo78a94332015-11-04 17:28:38 +01001'use strict';
2
3describe('The User List', () => {
4
5 var scope, element, isolatedScope, httpBackend;
6
7 beforeEach(module('xos.<%= name %>'));
8 beforeEach(module('templates'));
9
10 beforeEach(inject(function($httpBackend, $compile, $rootScope){
11
12 httpBackend = $httpBackend;
13 // Setting up mock request
Matteo Scandolofbd486c2016-04-13 10:19:55 -070014 $httpBackend.expectGET('/api/core/users/?no_hyperlinks=1').respond([
Matteo Scandolo78a94332015-11-04 17:28:38 +010015 {
16 email: '<%= user.email %>',
17 firstname: '<%= user.firstname %>',
18 lastname: '<%= user.lastname %>'
19 }
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('<%= user.email %>');
33 expect(isolatedScope.users[0].firstname).toEqual('<%= user.firstname %>');
34 expect(isolatedScope.users[0].lastname).toEqual('<%= user.lastname %>');
35 });
36
37});