diff options
Diffstat (limited to 'test/ngResource/resourceSpec.js')
| -rw-r--r-- | test/ngResource/resourceSpec.js | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/test/ngResource/resourceSpec.js b/test/ngResource/resourceSpec.js index 68c1b171..d971e8e7 100644 --- a/test/ngResource/resourceSpec.js +++ b/test/ngResource/resourceSpec.js @@ -877,8 +877,8 @@ describe("resource", function() { expect(user).toEqualData([ {id: 1, name: 'user1'} ]); }); }); - - describe('get', function(){ + + describe('get', function(){ it('should add them to the id', function() { $httpBackend.expect('GET', '/users/1.json').respond({id: 1, name: 'user1'}); var UserService = $resource('/users/:user_id.json', {user_id: '@id'}); @@ -908,7 +908,7 @@ describe("resource", function() { var UserService = $resource('/users/:user_id', {user_id: '@id'}, { get: { method: 'GET', - url: '/users/:user_id.json' + url: '/users/:user_id.json' } }); var user = UserService.get({user_id: 1}); @@ -1036,13 +1036,13 @@ describe("resource", function() { describe('resource', function() { var $httpBackend, $resource; - + beforeEach(module(function($exceptionHandlerProvider) { $exceptionHandlerProvider.mode('log'); })); - + beforeEach(module('ngResource')); - + beforeEach(inject(function($injector) { $httpBackend = $injector.get('$httpBackend'); $resource = $injector.get('$resource'); @@ -1054,14 +1054,16 @@ describe('resource', function() { var failureSpy = jasmine.createSpy('failureSpy'); $httpBackend.expect('GET', '/Customer/123').respond({id: 'abc'}); - + $resource('/Customer/123').query() .$promise.then(successSpy, function(e) { failureSpy(e.message); }); $httpBackend.flush(); expect(successSpy).not.toHaveBeenCalled(); - expect(failureSpy).toHaveBeenCalledWith( - '[$resource:badcfg] Error in resource configuration. Expected response to contain an array but got an object'); + expect(failureSpy).toHaveBeenCalled(); + expect(failureSpy.mostRecentCall.args[0]).toMatch( + /^\[\$resource:badcfg\] Error in resource configuration\. Expected response to contain an array but got an object/ + ); }); it('should fail if action expects an array but response is an object', function() { @@ -1069,14 +1071,16 @@ describe('resource', function() { var failureSpy = jasmine.createSpy('failureSpy'); $httpBackend.expect('GET', '/Customer/123').respond([1,2,3]); - + $resource('/Customer/123').get() .$promise.then(successSpy, function(e) { failureSpy(e.message); }); $httpBackend.flush(); expect(successSpy).not.toHaveBeenCalled(); - expect(failureSpy).toHaveBeenCalledWith( - '[$resource:badcfg] Error in resource configuration. Expected response to contain an object but got an array'); + expect(failureSpy).toHaveBeenCalled(); + expect(failureSpy.mostRecentCall.args[0]).toMatch( + /^\[\$resource:badcfg\] Error in resource configuration. Expected response to contain an object but got an array/ + ) }); |
