chore: added test for background rect dimensions

This commit is contained in:
Alexander Sage 2019-07-23 21:28:48 -07:00
parent 671a892b52
commit 8f6d148481
2 changed files with 21 additions and 0 deletions

3
__mocks__/d3.js vendored
View File

@ -4,6 +4,9 @@ let NewD3 = function () {
append: function () {
return NewD3()
},
lower: function () {
return this
},
attr: function () {
return this
},

View File

@ -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 () {