Leaflet/spec/suites/geometry/TransformationSpec.js

32 lines
863 B
JavaScript
Raw Permalink 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);
expect(p2).toEqual(new L.Point(24, 128));
});
it('assumes a scale of 1 if not specified', function () {
2013-02-05 19:51:27 +08:00
var p2 = t.transform(p);
expect(p2).toEqual(new L.Point(12, 64));
});
});
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);
expect(p3).toEqual(p);
});
it('assumes a scale of 1 if not specified', function () {
2013-02-05 19:51:27 +08:00
var p2 = t.transform(p);
expect(t.untransform(new L.Point(12, 64))).toEqual(new L.Point(10, 20));
});
});
2013-02-05 19:51:27 +08:00
});