Paul Van Eck 6d473eed7d Update node packages and styling
With the update of some linting packages, several style fixes
were needed to conform with the updated style guidelines.

Change-Id: If73036a6d4a3a2f6e93b15d1fa6ed3d253fdc7b1
2017-12-18 16:15:43 -08:00

40 lines
1.5 KiB
JavaScript

describe('Auth', function () {
'use strict';
var fakeApiUrl = 'http://foo.bar/v1';
var $window, $rootScope, $httpBackend;
beforeEach(function () {
$window = {location: { href: jasmine.createSpy()} };
module(function ($provide) {
$provide.constant('refstackApiUrl', fakeApiUrl);
$provide.value('$window', $window);
});
module('refstackApp');
inject(function (_$httpBackend_, _$rootScope_) {
$httpBackend = _$httpBackend_;
$rootScope = _$rootScope_;
});
$httpBackend.whenGET('/components/home/home.html')
.respond('<div>mock template</div>');
});
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);
});
});