From 8f6d1484817d3293df666e84d5973d34d57404a8 Mon Sep 17 00:00:00 2001 From: Alexander Sage Date: Tue, 23 Jul 2019 21:28:48 -0700 Subject: [PATCH] chore: added test for background rect dimensions --- __mocks__/d3.js | 3 +++ src/diagrams/sequence/sequenceDiagram.spec.js | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/__mocks__/d3.js b/__mocks__/d3.js index ca3a2822a..73e5482bd 100644 --- a/__mocks__/d3.js +++ b/__mocks__/d3.js @@ -4,6 +4,9 @@ let NewD3 = function () { append: function () { return NewD3() }, + lower: function () { + return this + }, attr: function () { return this }, diff --git a/src/diagrams/sequence/sequenceDiagram.spec.js b/src/diagrams/sequence/sequenceDiagram.spec.js index 50a801e7b..d9039e6c5 100644 --- a/src/diagrams/sequence/sequenceDiagram.spec.js +++ b/src/diagrams/sequence/sequenceDiagram.spec.js @@ -980,6 +980,24 @@ describe('when rendering a sequenceDiagram', function () { expect(bounds.stopx).toBe(0 + conf.width * 2 + conf.actorMargin) expect(bounds.stopy).toBe(0 + 2 * conf.messageMargin + conf.height + 3 * conf.boxMargin + conf.boxTextMargin) }) + it('it should draw background rect', function () { + renderer.bounds.init() + const str = ` + sequenceDiagram + Alice->Bob: Hello Bob, are you alright? + rect rgb(0, 0, 0) + Bob->Alice: I feel surrounded by darkness + end + ` + parser.parse(str) + renderer.draw(str, 'tst') + const bounds = renderer.bounds.getBounds() + expect(bounds.startx).toBe(0) + expect(bounds.starty).toBe(0) + + expect(bounds.stopx).toBe(0 + conf.width * 2 + conf.actorMargin) + expect(bounds.stopy).toBe(0 + 2 * conf.messageMargin + conf.height + 3 * conf.boxMargin) + }) }) describe('when rendering a sequenceDiagram with actor mirror activated', function () {