mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
@@ -8,6 +8,7 @@ describe('Auth Controller', function() {
|
||||
beforeEach(function(){
|
||||
module(function($provide) {
|
||||
$provide.value('Analytics', analyticsMock);
|
||||
$provide.value('Chat', { seenMessage: function() {} });
|
||||
});
|
||||
|
||||
inject(function(_$httpBackend_, $rootScope, $controller) {
|
||||
@@ -22,21 +23,29 @@ describe('Auth Controller', function() {
|
||||
})
|
||||
});
|
||||
|
||||
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();
|
||||
expect(user.authenticate).to.be.calledOnce;
|
||||
expect($window.alert).to.not.be.called;
|
||||
describe('logging in', function() {
|
||||
|
||||
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();
|
||||
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;
|
||||
});
|
||||
});
|
||||
|
||||
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;
|
||||
describe('clearMessage', function() {
|
||||
it('is Chat.seenMessage', inject(function(Chat) {
|
||||
expect(scope.clearMessages).to.eql(Chat.seenMessage);
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user