Files
refstack/refstack-ui/tests/unit/AuthSpec.js
sslypushenko 2b89f65ad4 Add filter for signed test results and related UI
With this patch users can list their own test results.

Change-Id: Ie2d944924f6ae966a13d0ca9908810c315ade5ab
2015-08-17 17:06:02 +03:00

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);
});
});