mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-04 04:59:40 +00:00
The way the tests are written now, the habitrpg module definition in static.js was clobbering the one in app.js. In other words, most of the tests weren't testing what they thought they were testing.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
describe('Auth Controller', function() {
|
|
|
|
beforeEach(module('habitrpgStatic'));
|
|
|
|
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() {
|
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
|
scope.auth();
|
|
$httpBackend.flush();
|
|
sinon.assert.calledOnce(user.authenticate);
|
|
sinon.assert.notCalled($window.alert);
|
|
});
|
|
|
|
it('should not log in users with incorrect uname / pass', function() {
|
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
|
scope.auth();
|
|
$httpBackend.flush();
|
|
sinon.assert.notCalled(user.authenticate);
|
|
sinon.assert.calledOnce($window.alert);
|
|
});
|
|
});
|
|
|
|
});
|