From 45311c668debec4648edfae65054f116a20fe053 Mon Sep 17 00:00:00 2001 From: hikerpig Date: Mon, 9 May 2022 19:23:16 +0800 Subject: [PATCH] test: add sequence artist test for boxes --- .../sequence-artist.spec.ts.snap | 161 ++++++++++++++++++ .../__tests__/sequence-artist.spec.ts | 11 ++ 2 files changed, 172 insertions(+) diff --git a/packages/pintora-diagrams/src/sequence/__tests__/__snapshots__/sequence-artist.spec.ts.snap b/packages/pintora-diagrams/src/sequence/__tests__/__snapshots__/sequence-artist.spec.ts.snap index e144cc45..f8af3db9 100644 --- a/packages/pintora-diagrams/src/sequence/__tests__/__snapshots__/sequence-artist.spec.ts.snap +++ b/packages/pintora-diagrams/src/sequence/__tests__/__snapshots__/sequence-artist.spec.ts.snap @@ -687,3 +687,164 @@ Object { }, } `; + +exports[`sequence-artist will render boxes 1`] = ` +Object { + "mark": Object { + "attrs": Object {}, + "children": Array [ + Object { + "attrs": Object {}, + "children": Array [ + Object { + "attrs": Object { + "fill": "#d6d3fa", + "stroke": "#3b4044", + }, + "type": "rect", + }, + Object { + "attrs": Object { + "fill": "#3b4044", + "fontFamily": "Source Code Pro, sans-serif", + "fontSize": 16, + "fontWeight": "bold", + "text": "group participants", + "textAlign": "center", + "textBaseline": "top", + }, + "type": "text", + }, + ], + "class": "sequence__participant-boxes", + "type": "group", + }, + Object { + "children": Array [ + Object { + "attrs": Object { + "stroke": "#3b4044", + }, + "class": "actor__line", + "type": "line", + }, + Object { + "attrs": Object { + "fill": "#fdb05e", + "radius": 4, + "stroke": "#3b4044", + }, + "type": "rect", + }, + Object { + "attrs": Object { + "fill": "#3b4044", + "fontFamily": "Source Code Pro, sans-serif", + "fontSize": 16, + "fontWeight": 400, + "text": "Alice", + "textAlign": "center", + "textBaseline": "middle", + }, + "type": "text", + }, + ], + "class": "actor", + "type": "group", + }, + Object { + "children": Array [ + Object { + "attrs": Object { + "stroke": "#3b4044", + }, + "class": "actor__line", + "type": "line", + }, + Object { + "attrs": Object { + "fill": "#fdb05e", + "radius": 4, + "stroke": "#3b4044", + }, + "type": "rect", + }, + Object { + "attrs": Object { + "fill": "#3b4044", + "fontFamily": "Source Code Pro, sans-serif", + "fontSize": 16, + "fontWeight": 400, + "text": "B", + "textAlign": "center", + "textBaseline": "middle", + }, + "type": "text", + }, + ], + "class": "actor", + "type": "group", + }, + Object { + "attrs": Object {}, + "children": Array [], + "class": "activations", + "type": "group", + }, + Object { + "children": Array [ + Object { + "attrs": Object { + "fill": "#fdb05e", + "radius": 4, + "stroke": "#3b4044", + }, + "type": "rect", + }, + Object { + "attrs": Object { + "fill": "#3b4044", + "fontFamily": "Source Code Pro, sans-serif", + "fontSize": 16, + "fontWeight": 400, + "text": "Alice", + "textAlign": "center", + "textBaseline": "middle", + }, + "type": "text", + }, + ], + "class": "actor", + "type": "group", + }, + Object { + "children": Array [ + Object { + "attrs": Object { + "fill": "#fdb05e", + "radius": 4, + "stroke": "#3b4044", + }, + "type": "rect", + }, + Object { + "attrs": Object { + "fill": "#3b4044", + "fontFamily": "Source Code Pro, sans-serif", + "fontSize": 16, + "fontWeight": 400, + "text": "B", + "textAlign": "center", + "textBaseline": "middle", + }, + "type": "text", + }, + ], + "class": "actor", + "type": "group", + }, + ], + "type": "group", + }, +} +`; diff --git a/packages/pintora-diagrams/src/sequence/__tests__/sequence-artist.spec.ts b/packages/pintora-diagrams/src/sequence/__tests__/sequence-artist.spec.ts index 3e93dda3..0053a21d 100644 --- a/packages/pintora-diagrams/src/sequence/__tests__/sequence-artist.spec.ts +++ b/packages/pintora-diagrams/src/sequence/__tests__/sequence-artist.spec.ts @@ -34,4 +34,15 @@ describe('sequence-artist', () => { const result = testDraw(code, { containerSize: { width: 300 } }) expect(Math.round(result.graphicIR.width)).toBe(300) }) + + it('will render boxes', () => { + const code = ` + sequenceDiagram + box #d6d3fa "group participants" + participant A as "Alice" + participant B + endbox + ` + expect(stripDrawResultForSnapshot(testDraw(code))).toMatchSnapshot() + }) })