habitica-self-host/test/spec/authCtrlSpec.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
// @TODO translations aren't loading
xdescribe('Auth Controller', function() {
describe('AuthCtrl', function(){
var scope, ctrl, user, $httpBackend, $window;
beforeEach(inject(function(_$httpBackend_, $rootScope, $controller) {
$httpBackend = _$httpBackend_;
scope = $rootScope.$new();
scope.loginUsername = 'user';
scope.loginPassword = 'pass';
$window = { location: { href: ""}, alert: sinon.spy() };
user = { user: {}, authenticate: sinon.spy() };
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
}));
it('should log in users with correct uname / pass', function() {
2013-12-24 01:38:15 +00:00
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
scope.auth();
$httpBackend.flush();
2014-01-04 02:28:43 +00:00
sinon.assert.calledOnce(user.authenticate);
sinon.assert.notCalled($window.alert);
});
it('should not log in users with incorrect uname / pass', function() {
2013-12-24 01:38:15 +00:00
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
scope.auth();
$httpBackend.flush();
2014-01-04 02:28:43 +00:00
sinon.assert.notCalled(user.authenticate);
sinon.assert.calledOnce($window.alert);
});
});
});