Add tests, remove unused code, encapsulate repeated code in functions

This commit is contained in:
Andreas Hocevar
2016-02-15 01:35:20 +01:00
parent a109062b1f
commit 952b99742e
5 changed files with 120 additions and 63 deletions

View File

@@ -0,0 +1,25 @@
goog.provide('ol.test.render.canvas');
describe('ol.render.canvas', function() {
describe('rotateAtOffset', function() {
it('rotates a canvas at an offset point', function() {
var context = {
translate: sinon.spy(),
rotate: sinon.spy()
};
ol.render.canvas.rotateAtOffset(context, Math.PI, 10, 10);
expect(context.translate.callCount).to.be(2);
expect(context.translate.firstCall.args).to.eql([10, 10]);
expect(context.translate.secondCall.args).to.eql([-10, -10]);
expect(context.rotate.callCount).to.be(1);
expect(context.rotate.firstCall.args).to.eql([Math.PI]);
});
});
});
goog.require('ol.render');
goog.require('ol.render.canvas');