Click here to Skip to main content
15,890,690 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i had created one controller to test jasmine test cases. i had written one http post method in jasmine test case but it can not execute. below code which i used in my controller

HTML
try
    {
        var $httpBackend;

        describe('mycontroller', function () {
            beforeEach(module('app'));

            it('scopeTestSpec',
                inject(function ($controller, $rootScope, $injector) {

                    var $scope = $rootScope.$new();
                    $controller('MyController',
                    {
                        $scope: $scope
                    });

                    $httpBackend = $injector.get('$httpBackend');

                    var sample = [];
                    sample = {
                        Email: "abc@gmail.com",
                        Password: "1111"
                    };               

                   $httpBackend.whenPOST('URL',sample).respond(function (method, url, data, headers) {
                        console.log('Received these data:', method, url, data, headers);
                    });

                    $httpBackend.flush();

                }));
        });
    } catch (e) {
        alert(e);
    }


What I have tried:

i had created one controller to test jasmine test cases. i had written one http post method in jasmine test case but it can not execute.
Posted
Updated 30-May-16 2:30am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900