1
1
import { Rule } from '../src/rule_class' ;
2
+ import { FlowchartCtrl } from '../src/flowchart_ctrl' ;
2
3
3
4
describe ( 'Rule' , ( ) => {
4
5
const data = Rule . getDefaultData ( ) ;
6
+ const ctrl = null ;
5
7
6
8
describe ( 'New' , ( ) => {
7
- const rule = new Rule ( '/.*/' , data ) ;
9
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
8
10
test ( 'Should be equals' , ( ) => {
9
11
expect ( rule . getData ( ) ) . toMatchSnapshot ( ) ;
10
12
} ) ;
@@ -15,7 +17,7 @@ describe('Rule', () => {
15
17
16
18
describe ( 'Create' , ( ) => {
17
19
test . skip ( 'addshape & remove' , ( ) => {
18
- const rule = new Rule ( '/.*/' , data ) ;
20
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
19
21
rule . addShapeMap ( pattern ) ;
20
22
expect ( rule . getShapeMaps ( ) . length ) . toBe ( 1 ) ;
21
23
rule . removeShapeMap ( 0 ) ;
@@ -25,26 +27,26 @@ describe('Rule', () => {
25
27
26
28
describe ( 'Match' , ( ) => {
27
29
test ( 'Match on one' , ( ) => {
28
- const rule = new Rule ( '/.*/' , data ) ;
30
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
29
31
rule . addShapeMap ( pattern ) ;
30
32
const sm = rule . getShapeMap ( 0 ) ;
31
33
sm . match ( 'Toto' ) ;
32
34
expect ( sm . match ( 'Toto' ) ) . toBeTruthy ( ) ;
33
35
} ) ;
34
36
35
37
test ( 'Match on all' , ( ) => {
36
- const rule = new Rule ( '/.*/' , data ) ;
38
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
37
39
rule . addShapeMap ( pattern ) ;
38
40
expect ( rule . matchShape ( 'Toto' ) ) . toBeTruthy ( ) ;
39
41
expect ( rule . matchShape ( 'Tata' ) ) . toBeFalsy ( ) ;
40
42
} ) ;
41
43
} ) ;
42
44
43
45
describe ( 'Colorize' , ( ) => {
44
- const rule = new Rule ( '/.*/' , data ) ;
46
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
45
47
// rule.data.thresholds = [50, 80];
46
- rule . addThreshold ( undefined , " COLOR1" , 50 ) ;
47
- rule . addThreshold ( undefined , " COLOR2" , 80 ) ;
48
+ rule . addThreshold ( undefined , ' COLOR1' , 50 ) ;
49
+ rule . addThreshold ( undefined , ' COLOR2' , 80 ) ;
48
50
const shape = rule . addShapeMap ( pattern ) ;
49
51
50
52
test ( 'isEligible always ERR should be true' , ( ) => {
@@ -70,22 +72,22 @@ describe('Rule', () => {
70
72
const pattern = '/.*Toto.*/' ;
71
73
72
74
test ( 'addshape & remove' , ( ) => {
73
- const rule = new Rule ( '/.*/' , data ) ;
75
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
74
76
rule . addTextMap ( pattern ) ;
75
77
expect ( rule . getTextMaps ( ) . length ) . toBe ( 1 ) ;
76
78
rule . removeTextMap ( 0 ) ;
77
79
expect ( rule . getTextMaps ( ) . length ) . toBe ( 0 ) ;
78
80
} ) ;
79
81
80
82
test ( 'Match on one' , ( ) => {
81
- const rule = new Rule ( '/.*/' , data ) ;
83
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
82
84
rule . addTextMap ( pattern ) ;
83
85
const sm = rule . getTextMap ( 0 ) ;
84
86
expect ( sm . match ( 'Toto' ) ) . toBeTruthy ( ) ;
85
87
} ) ;
86
88
87
89
test ( 'Match on all' , ( ) => {
88
- const rule = new Rule ( '/.*/' , data ) ;
90
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
89
91
rule . addTextMap ( pattern ) ;
90
92
expect ( rule . matchText ( 'Toto' ) ) . toBeTruthy ( ) ;
91
93
expect ( rule . matchText ( 'Tata' ) ) . toBeFalsy ( ) ;
@@ -95,22 +97,22 @@ describe('Rule', () => {
95
97
describe ( 'Link' , ( ) => {
96
98
const pattern = '/.*Toto.*/' ;
97
99
test ( 'addshape & remove' , ( ) => {
98
- const rule = new Rule ( '/.*/' , data ) ;
100
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
99
101
rule . addLinkMap ( pattern ) ;
100
102
expect ( rule . getLinkMaps ( ) . length ) . toBe ( 1 ) ;
101
103
rule . removeLinkMap ( 0 ) ;
102
104
expect ( rule . getLinkMaps ( ) . length ) . toBe ( 0 ) ;
103
105
} ) ;
104
106
105
107
test ( 'Match on one' , ( ) => {
106
- const rule = new Rule ( '/.*/' , data ) ;
108
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
107
109
rule . addLinkMap ( pattern ) ;
108
110
const sm = rule . getLinkMap ( 0 ) ;
109
111
expect ( sm . match ( 'Toto' ) ) . toBeTruthy ( ) ;
110
112
} ) ;
111
113
112
114
test ( 'Match on all' , ( ) => {
113
- const rule = new Rule ( '/.*/' , data ) ;
115
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
114
116
rule . addLinkMap ( pattern ) ;
115
117
expect ( rule . matchLink ( 'Toto' ) ) . toBeTruthy ( ) ;
116
118
expect ( rule . matchLink ( 'Tata' ) ) . toBeFalsy ( ) ;
@@ -119,7 +121,7 @@ describe('Rule', () => {
119
121
120
122
describe ( 'ValueMap' , ( ) => {
121
123
test ( 'addshape & remove' , ( ) => {
122
- const rule = new Rule ( '/.*/' , data ) ;
124
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
123
125
rule . data . mappingType = 1 ;
124
126
rule . addValueMap ( 1 , 'This 1' ) ;
125
127
expect ( rule . getValueMaps ( ) . length ) . toBe ( 1 ) ;
@@ -128,7 +130,7 @@ describe('Rule', () => {
128
130
} ) ;
129
131
130
132
test ( 'Mapping values' , ( ) => {
131
- const rule = new Rule ( '/.*/' , data ) ;
133
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
132
134
rule . data . mappingType = 1 ;
133
135
rule . data . type = 'string' ;
134
136
rule . addValueMap ( 1 , 'This 1' ) ;
@@ -141,7 +143,7 @@ describe('Rule', () => {
141
143
142
144
describe ( 'RangeMap' , ( ) => {
143
145
test ( 'addshape & remove' , ( ) => {
144
- const rule = new Rule ( '/.*/' , data ) ;
146
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
145
147
rule . data . mappingType = 2 ;
146
148
rule . data . type = 'string' ;
147
149
rule . addRangeMap ( 0 , 5 , 'Between 0 and 5' ) ;
@@ -151,7 +153,7 @@ describe('Rule', () => {
151
153
} ) ;
152
154
153
155
test ( 'Mapping values' , ( ) => {
154
- const rule = new Rule ( '/.*/' , data ) ;
156
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
155
157
rule . data . mappingType = 2 ;
156
158
rule . data . type = 'string' ;
157
159
rule . addRangeMap ( 0 , 5 , 'Between 0 and 5' ) ;
@@ -162,7 +164,7 @@ describe('Rule', () => {
162
164
} ) ;
163
165
164
166
test ( 'Mapping values upper and lower' , ( ) => {
165
- const rule = new Rule ( '/.*/' , data ) ;
167
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
166
168
rule . data . mappingType = 2 ;
167
169
rule . data . type = 'string' ;
168
170
rule . addRangeMap ( undefined , 33 , 'Lower than 33' ) ;
@@ -176,7 +178,7 @@ describe('Rule', () => {
176
178
177
179
describe ( 'Text replace' , ( ) => {
178
180
const data = Rule . getDefaultData ( ) ;
179
- const rule = new Rule ( '/.*/' , data ) ;
181
+ const rule = new Rule ( '/.*/' , data , ctrl ) ;
180
182
const text = 'This is my value' ;
181
183
const patternText = '/value/' ;
182
184
const formattedValue = '12.34' ;
0 commit comments