2013-11-08 05:54:33 +08:00
|
|
|
describe('PosAnimation', function () {
|
2013-07-12 01:30:15 +08:00
|
|
|
var el;
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
beforeEach(function () {
|
2013-07-12 01:30:15 +08:00
|
|
|
el = document.createElement('div');
|
|
|
|
this.subject = new L.PosAnimation();
|
|
|
|
this.subject._el = el;
|
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe('#_onStep', function () {
|
|
|
|
it("sets element position and fires step event if it is able to get current position", function () {
|
2013-07-12 01:30:15 +08:00
|
|
|
var point = new L.Point(5, 5, true);
|
|
|
|
sinon.stub(this.subject, '_getPos').returns(point);
|
|
|
|
this.subject.fire = sinon.stub();
|
|
|
|
this.subject._onStep();
|
|
|
|
expect(this.subject.fire.withArgs('step').calledOnce).to.be(true);
|
2013-11-08 05:54:33 +08:00
|
|
|
expect(L.DomUtil.getPosition(this.subject._el)).to.be(point);
|
2013-07-12 01:30:15 +08:00
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it('stops transition if a position returned', function () {
|
2013-07-12 01:30:15 +08:00
|
|
|
sinon.stub(this.subject, '_onTransitionEnd');
|
|
|
|
sinon.stub(this.subject, '_getPos').returns(undefined);
|
|
|
|
this.subject._onStep();
|
|
|
|
expect(this.subject._onTransitionEnd.calledOnce).to.be(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|