From 9236b29d011a5a4612f7f077be111353e0364e59 Mon Sep 17 00:00:00 2001 From: Sahat Yalkabov Date: Tue, 19 Aug 2014 14:38:23 -0400 Subject: [PATCH] updated tests --- test/$authSpec.js | 12 ++++++------ test/localSpec.js | 6 +----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/test/$authSpec.js b/test/$authSpec.js index e462ce14..50844ee6 100644 --- a/test/$authSpec.js +++ b/test/$authSpec.js @@ -51,16 +51,16 @@ describe('$auth provider', function() { expect($location.path()).toEqual('/login'); })); - it('should be able to handle signup errors', inject(function($auth, $httpBackend) { + it('should be able to handle signup errors', inject(function(Local, $httpBackend) { var user = { email: 'foo@bar.com', password: '1234' }; var rejected = false; - $httpBackend.expectPOST('/auth/signup').respond(404); + $httpBackend.expectPOST('/auth/signup').respond(400); - $auth.signup(user).then(angular.noop, function() { + Local.signup(user).catch(function() { rejected = true; }); @@ -95,9 +95,9 @@ describe('$auth provider', function() { expect($location.path()).toEqual('/login'); })); - it('should have a isAuthenticated function', inject(function($auth) { - var isAuthed = $auth.isAuthenticated(); - expect($auth.isAuthenticated).toBeDefined(); + it('should have a isAuthenticated function', inject(function(Local) { + var isAuthed = Local.isAuthenticated(); + expect(Local.isAuthenticated).toBeDefined(); expect(isAuthed).toBe(false); })); }); diff --git a/test/localSpec.js b/test/localSpec.js index a7da21e8..7cb03878 100644 --- a/test/localSpec.js +++ b/test/localSpec.js @@ -38,7 +38,7 @@ describe('Email and password flow', function() { $httpBackend.expectPOST('/auth/login').respond(401, 'Wrong email or password'); Local.login(user).catch(function(response) { - result = response; + result = response.data; }); $httpBackend.flush(); @@ -81,9 +81,5 @@ describe('Email and password flow', function() { expect(Local.isAuthenticated).toBeDefined(); expect(angular.isFunction(Local.isAuthenticated)).toBe(true); })); - - it('should have a isAuthenticated function', inject(function(Local) { - expect(Local.isAuthenticated()).toBe(false); - })); });