mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
* Added a task to Gruntfile to use website/src/i18n.js to generate a small JS file to be loaded in Karma env which sets window.env.translations to the i18n.translations['en']. * Added new Grunt task to build:dev * Updated Karma specs to reenable testing where possible, updating comments where not.
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
describe('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() {
|
|
$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);
|
|
});
|
|
});
|
|
|
|
});
|