123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import {
- getNewAttachPoint
- } from 'lib/util/AttachUtil';
- describe('AttachUtil', function() {
- describe('#getNewAttachPoint', function() {
- it('should return new point\'s position delta for growing', function() {
- // given
- var point = {
- x: -2,
- y: 2
- };
- var oldBounds = {
- x: -2,
- y: -2,
- width: 4,
- height: 4
- };
- var newBounds = {
- x: -2,
- y: -2,
- width: 8,
- height: 8
- };
- // then
- expect(getNewAttachPoint(point, oldBounds, newBounds)).to.eql({ x: -2, y: 6 });
- });
- it('should return new point\'s position delta for shrinking', function() {
- // given
- var point = {
- x: -4,
- y: 4
- };
- var oldBounds = {
- x: -4,
- y: -4,
- width: 8,
- height: 8
- };
- var newBounds = {
- x: -4,
- y: -4,
- width: 4,
- height: 4
- };
- // then
- expect(getNewAttachPoint(point, oldBounds, newBounds)).to.eql({ x: -4, y: 0 });
- });
- it('should return new point\'s position delta', function() {
- // given
- var point = {
- x: 21,
- y: 12
- };
- var oldBounds = {
- x: 18,
- y: 8,
- width: 4,
- height: 4
- };
- var newBounds = {
- x: 18,
- y: 8,
- width: 10,
- height: 2
- };
- // then
- expect(getNewAttachPoint(point, oldBounds, newBounds)).to.eql({ x: 26, y: 10 });
- });
- });
- });
|