Leaflet/spec/suites/geometry/TransformationSpec.js

42 lines
1.1 KiB
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);
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
});
});
describe('#constructor', function () {
it("allows an array property for a", function () {
var t2 = L.transformation([1, 2, 3, 4]);
expect(t._a).to.eql(t2._a);
expect(t._b).to.eql(t2._b);
expect(t._c).to.eql(t2._c);
expect(t._d).to.eql(t2._d);
});
});
2013-02-05 19:51:27 +08:00
});