From 34062cfa7731ab0c0d1df94b931fede0c57f1f09 Mon Sep 17 00:00:00 2001 From: Ulrich-Matthias Schäfer Date: Sun, 13 Jun 2021 22:39:18 +0200 Subject: fix group move bug when group contains elements without dimensions, update deps --- spec/spec/modules/core/containerGeometry.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/spec/modules/core/containerGeometry.js b/spec/spec/modules/core/containerGeometry.js index 7bbd2c9..740f99f 100644 --- a/spec/spec/modules/core/containerGeometry.js +++ b/spec/spec/modules/core/containerGeometry.js @@ -1,6 +1,6 @@ /* globals describe, expect, it, jasmine, spyOn, container */ -import { Box, G, Rect, SVG } from '../../../../src/main.js' +import { Box, create, Element, G, Rect, SVG } from '../../../../src/main.js' const { any, objectContaining } = jasmine @@ -42,6 +42,23 @@ describe('containerGeometry.js', () => { expect(newBox.w).toBeCloseTo(oldBox.w, 4) expect(newBox.h).toBeCloseTo(oldBox.h, 4) }) + + it('it does not fail when hitting elements without bbox', () => { + const canvas = SVG().addTo(container) + const g = canvas.group() + + g.add(new Rect({ width: 100, height: 120, x: 10, y: 20 })) + g.add(new Rect({ width: 70, height: 100, x: 50, y: 60 })) + g.add(new Element(create('title'))) + + const fn = () => g.dmove(10, 10) + expect(fn).not.toThrowError() + + const box = g.bbox() + expect(box).toEqual(objectContaining({ + x: 20, y: 30, width: box.width, height: box.height + })) + }) }) describe('dx()', () => { -- cgit v1.2.3