mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
tests: Remove unnecessary describe closure in auth ctrl spec
This commit is contained in:
@@ -1,45 +1,42 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
describe('Auth Controller', function() {
|
describe('Auth Controller', function() {
|
||||||
|
var scope, ctrl, user, $httpBackend, $window;
|
||||||
|
|
||||||
describe('AuthCtrl', function(){
|
beforeEach(function(){
|
||||||
var scope, ctrl, user, $httpBackend, $window;
|
module(function($provide) {
|
||||||
|
$provide.value('Analytics', analyticsMock);
|
||||||
beforeEach(function(){
|
$provide.value('Chat', { seenMessage: function() {} });
|
||||||
module(function($provide) {
|
|
||||||
$provide.value('Analytics', analyticsMock);
|
|
||||||
$provide.value('Chat', { seenMessage: function() {} });
|
|
||||||
});
|
|
||||||
|
|
||||||
inject(function(_$httpBackend_, $rootScope, $controller) {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
scope = $rootScope.$new();
|
|
||||||
scope.loginUsername = 'user';
|
|
||||||
scope.loginPassword = 'pass';
|
|
||||||
$window = { location: { href: ""}, alert: sandbox.spy() };
|
|
||||||
user = { user: {}, authenticate: sandbox.spy() };
|
|
||||||
|
|
||||||
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('logging in', function() {
|
inject(function(_$httpBackend_, $rootScope, $controller) {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
scope = $rootScope.$new();
|
||||||
|
scope.loginUsername = 'user';
|
||||||
|
scope.loginPassword = 'pass';
|
||||||
|
$window = { location: { href: ""}, alert: sandbox.spy() };
|
||||||
|
user = { user: {}, authenticate: sandbox.spy() };
|
||||||
|
|
||||||
it('should log in users with correct uname / pass', function() {
|
ctrl = $controller('AuthCtrl', {$scope: scope, $window: $window, User: user});
|
||||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
})
|
||||||
scope.auth();
|
});
|
||||||
$httpBackend.flush();
|
|
||||||
expect(user.authenticate).to.be.calledOnce;
|
|
||||||
expect($window.alert).to.not.be.called;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not log in users with incorrect uname / pass', function() {
|
describe('logging in', function() {
|
||||||
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
|
||||||
scope.auth();
|
it('should log in users with correct uname / pass', function() {
|
||||||
$httpBackend.flush();
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond({id: 'abc', token: 'abc'});
|
||||||
expect(user.authenticate).to.not.be.called;
|
scope.auth();
|
||||||
expect($window.alert).to.be.calledOnce;
|
$httpBackend.flush();
|
||||||
});
|
expect(user.authenticate).to.be.calledOnce;
|
||||||
|
expect($window.alert).to.not.be.called;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not log in users with incorrect uname / pass', function() {
|
||||||
|
$httpBackend.expectPOST('/api/v2/user/auth/local').respond(404, '');
|
||||||
|
scope.auth();
|
||||||
|
$httpBackend.flush();
|
||||||
|
expect(user.authenticate).to.not.be.called;
|
||||||
|
expect($window.alert).to.be.calledOnce;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user