bpmn-js 0.20.7 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,133 @@
1
+ 'use strict';
2
+
3
+ /* global bootstrapViewer, inject */
4
+
5
+
6
+ var labelEditingModule = require('../../../../lib/features/label-editing'),
7
+ coreModule = require('../../../../lib/core'),
8
+ draggingModule = require('diagram-js/lib/features/dragging'),
9
+ modelingModule = require('diagram-js/lib/features/modeling');
10
+
11
+ describe('features - label-editing preview', function() {
12
+
13
+ var diagramXML = require('../../../fixtures/bpmn/features/label-editing/labels.bpmn');
14
+
15
+ var testModules = [ labelEditingModule, coreModule, draggingModule, modelingModule ];
16
+
17
+ beforeEach(bootstrapViewer(diagramXML, { modules: testModules }));
18
+
19
+ describe('activate', function() {
20
+
21
+ it('[external labels AND text annotations ] should add marker to hide element on activate', inject(function(directEditing, elementRegistry) {
22
+
23
+ // given
24
+ var textAnnotation = elementRegistry.get('TextAnnotation_1');
25
+
26
+ // when
27
+ directEditing.activate(textAnnotation);
28
+
29
+ // then
30
+ var gfx = elementRegistry.getGraphics(textAnnotation);
31
+
32
+ expect(gfx.classList.contains('djs-element-hidden')).to.be.true;
33
+ }));
34
+
35
+
36
+ it('[internal labels] should add marker to hide label on activate', inject(function(directEditing, elementRegistry) {
37
+
38
+ // given
39
+ var task = elementRegistry.get('Task_1');
40
+
41
+ // when
42
+ directEditing.activate(task);
43
+
44
+ // then
45
+ var gfx = elementRegistry.getGraphics(task);
46
+
47
+ expect(gfx.classList.contains('djs-label-hidden')).to.be.true;
48
+ }));
49
+
50
+ });
51
+
52
+
53
+ describe('resize', function() {
54
+
55
+ it('[text annotations] should resize preview on resize', inject(function(directEditing, elementRegistry, eventBus, labelEditingPreview) {
56
+
57
+ // given
58
+ var textAnnotation = elementRegistry.get('TextAnnotation_1');
59
+ directEditing.activate(textAnnotation);
60
+
61
+ // when
62
+ eventBus.fire('directEditing.resize', {
63
+ width: 200,
64
+ height: 200,
65
+ dx: 100,
66
+ dy: 100
67
+ });
68
+
69
+ // then
70
+ var bounds = labelEditingPreview.path.getBBox();
71
+
72
+ expect(bounds).to.eql({ x: 0, y: 0, width: 10, height: 300 });
73
+ }));
74
+
75
+
76
+ it('[text annotations] should resize preview below 0', inject(function(directEditing, elementRegistry, eventBus, labelEditingPreview) {
77
+
78
+ // given
79
+ var textAnnotation = elementRegistry.get('TextAnnotation_1');
80
+ directEditing.activate(textAnnotation);
81
+
82
+ // when
83
+ eventBus.fire('directEditing.resize', {
84
+ width: 200,
85
+ height: 200,
86
+ dx: -300,
87
+ dy: -300
88
+ });
89
+
90
+ // then
91
+ var bounds = labelEditingPreview.path.getBBox();
92
+
93
+ expect(bounds).to.eql({ x: 0, y: 0, width: 10, height: 0 });
94
+ }));
95
+
96
+ });
97
+
98
+
99
+ describe('complete/cancel', function() {
100
+
101
+ it('[external labels AND text annotations] should remove marker to hide element on complete', inject(function(directEditing, elementRegistry) {
102
+
103
+ // given
104
+ var textAnnotation = elementRegistry.get('TextAnnotation_1');
105
+ directEditing.activate(textAnnotation);
106
+
107
+ // when
108
+ directEditing.complete();
109
+
110
+ // then
111
+ var gfx = elementRegistry.getGraphics(textAnnotation);
112
+
113
+ expect(gfx.classList.contains('djs-element-hidden')).to.be.false;
114
+ }));
115
+
116
+
117
+ it('[internal labels] should remove marker to hide label on complete', inject(function(directEditing, elementRegistry) {
118
+
119
+ // given
120
+ var task = elementRegistry.get('Task_1');
121
+ directEditing.activate(task);
122
+
123
+ // when
124
+ directEditing.complete();
125
+
126
+ // then
127
+ var gfx = elementRegistry.getGraphics(task);
128
+
129
+ expect(gfx.classList.contains('djs-label-hidden')).to.be.false;
130
+ }));
131
+
132
+ });
133
+ });