angularjs - Unit Test Dropbox -
i trying create unit test karma jasmine interacts dropbox api.
below test. compiles directive, runs click on it. checks file picker window opens. checking window opening in way works on other tests, in instance fails because referenceerror: can't find variable: dropbox
. because not in test. file hosted directly dropbox via https://www.dropbox.com/static/api/2/dropins.js, cannot seem inject it... question is, how make dropbox
available in case?
it(": clicking button should open dropbox picker window", function(){ var element = $compile("<span data-dropbox extensions=\"extensions\"></span>")($scope); $scope.$digest(); var thebutton = element.find('button'); spyon($window, 'open'); thebutton.triggerhandler('click'); expect($window.open).tohavebeencalled(); });
thanks in advance
your approach wrong. trying unit test button click. not unit test button click, unit test controller / service/ directive code.
to test button click use protractor. e2e test (end-to-end).
Comments
Post a Comment