Commit b311140e authored by Evren Kutar's avatar Evren Kutar

login olduktan sonra redirect senaryosu testi eklendi (expect)

kullanılmayanlar temizlendi
parent 6490a67e
...@@ -55,22 +55,24 @@ describe('zaerp.auth module', function () { ...@@ -55,22 +55,24 @@ describe('zaerp.auth module', function () {
); );
it('ensures user can log in', function() { it('ensures user can log in', function() {
// expect current scope to contain username // todo: after backend api ready implement this
});
it('ensures path has changed', function() {
// expect path to equal '/dashboard'
}); });
it('should get login success', it('should get login success',
inject(function(LoginService, $httpBackend) { inject(function(LoginService, $httpBackend, $location) {
// use httpBackend to imitate login api
$httpBackend.expectGET('http://127.0.0.1:8000/login?email=test@test.com&password=password&') $httpBackend.expectGET('http://127.0.0.1:3000/api/login?email=test@test.com&password=password&')
.respond(204, {'id': 1, 'user': {'id': 12, 'role': 'admin'}}); // todo: with real api change response data from list to obj
.respond(200, [{'id': 1, 'user': {'id': 12, 'role': 'admin'}, 'success': true}]);
var cred = {email: 'test@test.com', password: 'password'}; var cred = {email: 'test@test.com', password: 'password'};
LoginService.login(cred) LoginService.login(cred)
.then(function(data) { .then(function(data) {
expect(data).not.toBe(null); expect(data).not.toBe(null);
// after login path need to be change dashboard
expect($location.path()).toBe('/dashboard');
}); });
$httpBackend.flush(); $httpBackend.flush();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment