mercredi 29 juillet 2015

How to unit test a modal in my case

I am trying to test my modal in my script. but getting an error like

Unexpected request: GET modal/view.html. Here are my codes:

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

controller

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

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

Getting error: Unexpected request: GET modal/view.html modal/view.html is from the template params inside the modal

I am not sure how to patch this error in my case. Can anyone help me about it? Thanks a lot!

Aucun commentaire:

Enregistrer un commentaire