Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. app.controller('MainCtrl', function($scope, $http, factoryGetJSONFile) {
  2.  
  3. $scope.name = 'World';
  4.  
  5. factoryGetJSONFile.getMyData(function(data) {
  6. $scope.Addresses = data.Addresses.AddressList;
  7. $scope.People = data.Names.People;
  8. $scope.Country = data.Country;
  9. });
  10.  
  11. });
  12.  
  13. describe('with httpBackend', function () {
  14. var app;
  15. beforeEach(function () {
  16. app = angular.mock.module('plunker')
  17. });
  18.  
  19. describe('MyCtrl', function () {
  20. var scope, ctrl, theService, httpMock;
  21.  
  22. beforeEach(inject(function ($controller, $rootScope, factoryGetJSONFile, $httpBackend) {
  23. httpMock = $httpBackend;
  24. scope = $rootScope.$new();
  25. ctrl = $controller('MyCtrl', {
  26. $scope: scope,
  27. factoryGetJSONFile: factoryGetJSONFile,
  28. $httpBackend: httpMock
  29. });
  30. }));
  31.  
  32. it("should make a GET call to data.json", function () {
  33. console.log("********** SERVICE ***********");
  34. httpMock.expectGET("data.json?").respond(data);
  35.  
  36. console.log(data.Addresses);
  37. console.log(data.Names);
  38. console.log(data.Country);
  39. //expect(factoryGetJSONFile.getMyData()).toBeDefined();
  40. httpMock.flush();
  41. });
  42. })
  43. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement