如何在我的案例中对模态进行单元测试

时间:2015-07-29 19:31:02

标签: angularjs unit-testing

我正在尝试在我的脚本中测试我的模态。但得到像

这样的错误

Unexpected request: GET modal/view.html。这是我的代码:

describe('test controller', function () {
        var myCtrl, scope, rootScope, $httpBackend;

        beforeEach(module('myApp'));
        beforeEach(inject(function (_$controller_, _$httpBackend_, _$rootScope_) {
            rootScope   = _$rootScope_;
            scope        = _$rootScope_.$new();
            $httpBackend = _$httpBackend_:

            myCtrl = _$controller_('myCtrl', {
                $scope: scope
            });
        }));

        describe('test', function() {
            it('it should load modal' , function() {
                scope.loadModal();
                //some http request tests
                $httpBackend.flush();
            });
        });
    });

控制器

  $scope.loadModal = function() {
       //some http request codes…

        $scope.modal = $modal({
            template: 'modal/view.html',
            scope: $scope
        });
    };

获取错误:Unexpected request: GET modal/view.html modal / view.html来自模态

中的模板参数

我不知道如何在我的情况下修补此错误。任何人都可以帮我吗?非常感谢!

0 个答案:

没有答案