mardi 26 mai 2015

Mock document.getElemetById('.form').getContext('2d') using sinon

I'm using karma, mocha, chai, sinon and Angular mocks for my unit testing. In my $scope.loadChart, I'm drawing a chart in my canvas tag. I'm using http://www.chartjs.org/ to draw the charts.

Chartjs requires this piece of code, document.getElemetById('#canvas').getContext('2d'). How do I stub this in Sinon? My test is stuck with this line.

Aucun commentaire:

Enregistrer un commentaire