0

How do i access a json object in the controller spec ? tried a lot of options of the net with jasmine getJson Fixtures and httpbackend but nothing seems to work.

beforeEach(inject(function ($injector,$controller, $rootScope, $q, _$timeout_,_$httpBackend){

$httpBackend = $injector.get('$httpBackend');
jasmine.getJSONFixtures().fixturesPath='base/client/json';

$httpBackend.whenGET('../api').respond(
    getJSONFixture('AuthenticatDI_Response.json')
);

scope = $rootScope.$new();
//declare the controller and inject our empty scope
    $controller('DashboardCtrl', {$scope: scope});
}));

afterEach(function() {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
 });

it('should have some result', function() {
 console.log(scope);
 $httpBackend.flush();
 expect(scope.userProfile.length).toBe(1);

});
2
  • 2
    Huh? Showing us an example of your code would help. Commented Dec 1, 2014 at 14:57
  • Voted to close due to the lack of an error and the date of the question. Commented Mar 23, 2016 at 1:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.