Httppost方法没有使用jasmine进行调用 [英] Httppost method is not invoking using jasmine

查看:81
本文介绍了Httppost方法没有使用jasmine进行调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个控制器来测试茉莉花测试用例。我在jasmine测试用例中编写了一个http post方法,但它无法执行。下面我在我的控制器中使用的代码



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

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);
    }





我的尝试:



i创建了一个控制器来测试jasmine测试用例。我在jasmine测试用例中编写了一个http post方法,但它无法执行。



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.

推荐答案

httpBackend;

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

it('scopeTestSpec',
注入(函数(
httpBackend; describe('mycontroller', function () { beforeEach(module('app')); it('scopeTestSpec', inject(function (


controller,
controller,


rootScope,
rootScope,


这篇关于Httppost方法没有使用jasmine进行调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆