Last active
February 1, 2016 07:10
-
-
Save sumitk/5a29b929ebfa540c5d0a to your computer and use it in GitHub Desktop.
Revisions
-
sumitk revised this gist
Feb 1, 2016 . No changes.There are no files selected for viewing
-
sumitk created this gist
Feb 1, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ angular.module('myApp.services', ['ngResource']) .factory('TestingService', ['$resource', function($resource) { return $resource('/api/v1/values', {}, { getValues: { method: 'GET' } }); }]); describe('Testing services', function() { beforeEach(function(){ module('myApp.services'); this.addMatchers({ toEqualData: function(expected) { return angular.equals(this.actual, expected); } }); }); afterEach(function() { inject(function($httpBackend) { $httpBackend.verifyNoOutstandingExpectation(); $httpBackend.verifyNoOutstandingRequest(); }); }); describe('TestingService', function() { it('should work', inject(['$rootScope', '$httpBackend', 'TestingService', function ($rootScope, $httpBackend, testingService) { $httpBackend.expectGET('/api/v1/values').respond( { key: 'value' } ); var result = testingService.getValues(); $httpBackend.flush(); expect(result).toEqualData( { key: 'value' } ); alert(angular.toJson(result, true)); }]) ); }); });