With this patch users can list their own test results. Change-Id: Ie2d944924f6ae966a13d0ca9908810c315ade5ab
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
describe('Auth', function () {
|
|
'use strict';
|
|
|
|
var fakeApiUrl = 'http://foo.bar/v1';
|
|
var $window;
|
|
beforeEach(function () {
|
|
$window = {location: { href: jasmine.createSpy()} };
|
|
module(function ($provide) {
|
|
$provide.constant('refstackApiUrl', fakeApiUrl);
|
|
$provide.value('$window', $window);
|
|
});
|
|
module('refstackApp');
|
|
});
|
|
|
|
var $rootScope, $httpBackend;
|
|
beforeEach(inject(function (_$httpBackend_, _$rootScope_) {
|
|
$httpBackend = _$httpBackend_;
|
|
$rootScope = _$rootScope_;
|
|
}));
|
|
|
|
it('should show signin url for signed user', function () {
|
|
$httpBackend.expectGET(fakeApiUrl +
|
|
'/profile').respond({'openid': 'foo@bar.com',
|
|
'email': 'foo@bar.com',
|
|
'fullname': 'foo' });
|
|
$httpBackend.flush();
|
|
$rootScope.auth.doSignIn();
|
|
expect($window.location.href).toBe(fakeApiUrl + '/auth/signin');
|
|
expect($rootScope.auth.isAuthenticated).toBe(true);
|
|
});
|
|
|
|
it('should show signout url for not signed user', function () {
|
|
$httpBackend.expectGET(fakeApiUrl +
|
|
'/profile').respond(401);
|
|
$httpBackend.flush();
|
|
$rootScope.auth.doSignOut();
|
|
expect($window.location.href).toBe(fakeApiUrl + '/auth/signout');
|
|
expect($rootScope.auth.isAuthenticated).toBe(false);
|
|
});
|
|
});
|