Leaflet/spec/suites/geometry/TransformationSpec.js

32 lines
863 B
JavaScript
Raw Normal View History

describe("Transformation", function () {
var t, p;
2013-02-05 19:51:27 +08:00
beforeEach(function () {
t = new L.Transformation(1, 2, 3, 4);
p = new L.Point(10, 20);
});
2013-02-05 19:51:27 +08:00
describe('#transform', function () {
it("performs a transformation", function () {
2013-02-05 19:51:27 +08:00
var p2 = t.transform(p, 2);
2013-03-02 05:49:20 +08:00
expect(p2).to.eql(new L.Point(24, 128));
2013-02-05 19:51:27 +08:00
});
it('assumes a scale of 1 if not specified', function () {
2013-02-05 19:51:27 +08:00
var p2 = t.transform(p);
2013-03-02 05:49:20 +08:00
expect(p2).to.eql(new L.Point(12, 64));
2013-02-05 19:51:27 +08:00
});
});
2013-02-05 19:51:27 +08:00
describe('#untransform', function () {
it("performs a reverse transformation", function () {
2013-02-05 19:51:27 +08:00
var p2 = t.transform(p, 2);
var p3 = t.untransform(p2, 2);
2013-03-02 05:49:20 +08:00
expect(p3).to.eql(p);
2013-02-05 19:51:27 +08:00
});
it('assumes a scale of 1 if not specified', function () {
2013-02-05 19:51:27 +08:00
var p2 = t.transform(p);
2013-03-02 05:49:20 +08:00
expect(t.untransform(new L.Point(12, 64))).to.eql(new L.Point(10, 20));
2013-02-05 19:51:27 +08:00
});
});
2013-02-05 19:51:27 +08:00
});