Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.controller('MainCtrl', function($scope, $http, factoryGetJSONFile) {
- $scope.name = 'World';
- factoryGetJSONFile.getMyData(function(data) {
- $scope.Addresses = data.Addresses.AddressList;
- $scope.People = data.Names.People;
- $scope.Country = data.Country;
- });
- });
- describe('with httpBackend', function () {
- var app;
- beforeEach(function () {
- app = angular.mock.module('plunker')
- });
- describe('MyCtrl', function () {
- var scope, ctrl, theService, httpMock;
- beforeEach(inject(function ($controller, $rootScope, factoryGetJSONFile, $httpBackend) {
- httpMock = $httpBackend;
- scope = $rootScope.$new();
- ctrl = $controller('MyCtrl', {
- $scope: scope,
- factoryGetJSONFile: factoryGetJSONFile,
- $httpBackend: httpMock
- });
- }));
- it("should make a GET call to data.json", function () {
- console.log("********** SERVICE ***********");
- httpMock.expectGET("data.json?").respond(data);
- console.log(data.Addresses);
- console.log(data.Names);
- console.log(data.Country);
- //expect(factoryGetJSONFile.getMyData()).toBeDefined();
- httpMock.flush();
- });
- })
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement