I mean starting of the beforeEach() method.
On Sun, May 11, 2014 at 10:46 AM, Tandon, Rishi <[email protected]>wrote: > Could you try putting spyOn() at starting of the spyOn() method. > > > On Sun, May 11, 2014 at 9:44 AM, Diego Freitas <[email protected]>wrote: > >> Hey guys, >> >> I'm having trouble doing my Jasmine Tests http calls to test my REST API >> made in Node.JS. This is my first angularApplication ... Could anyone >> please point out what I'm doing wrong? >> >> My Spec is below and this is the link of my application: >> https://github.com/diegofss11/contact-list-application/tree/BranchOnTest >> >> describe('ContactService - Testing CRUD Operations', function(){ >>> var myServiceMock, $httpBackend, >>> BASE_URL = "http://localhost:3000", >>> mockContacts = [ >>> { >>> name: 'Diego Souza', >>> address: 'Hudson Street', >>> phone: '553188848176' >>> }, >>> { >>> name: 'Albert Silva', >>> address: 'Mkt Street', >>> phone: '1456847585' >>> } >>> ]; >>> >>> //mock contactListApp >>> beforeEach(module('contactListApp')) >>> >>> beforeEach(inject(function (ContactService, $httpBackend){ >>> $httpBackendMock = $httpBackend; >>> myServiceMock = ContactService; >>> $httpBackendMock.expectGET(BASE_URL + '/contacts/').respond( >>> {"Success": true,"ErrorMessage": >>> "","Result":[mockContacts]}); >>> spyOn(myServiceMock, 'findAll').andCallThrough(); // Calling of >>> the 'findAll' method is ensured >>> })); >>> >>> it('should find all the contacts', function(){ >>> expect(myServiceMock.findAll).toHaveBeenCalled(); >>> $httpBackendMock.flush(); >>> }) >>> }) >> >> >> Thank you so much all !!! >> >> -- >> You received this message because you are subscribed to the Google Groups >> "AngularJS" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/angular. >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > *Rishi Tandon* > Pearson Learning Technology Group > > Mobile: (310) 926-9032 > > Pearson > Always Learning > Learn more at www.pearson.com > -- *Rishi Tandon* Pearson Learning Technology Group Mobile: (310) 926-9032 Pearson Always Learning Learn more at www.pearson.com -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
