From 2e0843c22691b3f49e44c2f162b2987033cec2af Mon Sep 17 00:00:00 2001 From: ashishjain0512 Date: Tue, 23 Jul 2019 06:41:45 -0700 Subject: [PATCH] Added Jest test case for 'should be possible to apply a class to a vertex directly' use-case --- src/diagrams/flowchart/parser/flow.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/diagrams/flowchart/parser/flow.spec.js b/src/diagrams/flowchart/parser/flow.spec.js index 8ce961993..9cc297e86 100644 --- a/src/diagrams/flowchart/parser/flow.spec.js +++ b/src/diagrams/flowchart/parser/flow.spec.js @@ -1685,6 +1685,22 @@ describe('when parsing ', function () { expect(classes['exClass'].styles[0]).toBe('background:#bbb') expect(classes['exClass'].styles[1]).toBe('border:1px solid red') }) + it('should be possible to apply a class to a vertex directly', function () { + let statement = '' + + statement = statement + 'graph TD;' + '\n' + statement = statement + 'classDef exClass background:#bbb,border:1px solid red;' + '\n' + statement = statement + 'a-->b[test].exClass;' + '\n' + + const res = flow.parser.parse(statement) + const vertices = flow.parser.yy.getVertices() + const classes = flow.parser.yy.getClasses() + + expect(classes['exClass'].styles.length).toBe(2) + expect(vertices['b'].classes[0]).toBe('exClass') + expect(classes['exClass'].styles[0]).toBe('background:#bbb') + expect(classes['exClass'].styles[1]).toBe('border:1px solid red') + }) it('should be possible to apply a class to a comma separated list of vertices', function () { let statement = ''