Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I got it to work.<br> jquery and jquery popover js files need to be loaded before angular.js during the test. This order should be specified in the testacular.conf.js file. Also, the url for http was missing ‘/’. Here is the code that is working for me:</p> <hr> <pre class="lang-js prettyprint-override"><code>angular.module('directives', []). directive('popOver', function($http) { return { restrict: 'C', link: function(scope, element, attr) { element.bind('mouseover', function(e) { $http.get("someurl/" + attr.chatid + ".json").success(function(data) { element.popover({ content: data.firstName + " " + data.lastName }); }); }); } } }) 'user strict' describe('directives', function() { beforeEach(module('directives')); describe('popOver', function() { var $scope, compile, location, $httpBackend, elm; beforeEach(inject(function($rootScope, $compile, _$httpBackend_) { $scope = $rootScope.$new(); compile = $compile; $httpBackend = _$httpBackend_; elm = angular.element('&lt;i class="pop-over" data-placement="top" data-chatid="testChatId" &gt; &lt;/i&gt;'); compile(elm)($scope); })); it('should call element.popover()', function() { $httpBackend.expectGET('someurl/testChatId.json'). respond([{ firstName: 'test', lastName: 'user' }]); //spyOn(elm, 'popover').andCallThrough(); spyOn($.fn, 'popover').andCallThrough(); elm.trigger('mouseover'); $httpBackend.flush(); //expect(elm.popover).toHaveBeenCalled(); expect($.fn.popover).toHaveBeenCalled(); }); }); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload