Skip to content

Commit 66f729b

Browse files
committed
test
1 parent 2e1724f commit 66f729b

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

spec/rule.test.ts

+21-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Rule } from '../src/rule_class';
2+
import { FlowchartCtrl } from '../src/flowchart_ctrl';
23

34
describe('Rule', () => {
45
const data = Rule.getDefaultData();
6+
const ctrl = null;
57

68
describe('New', () => {
7-
const rule = new Rule('/.*/', data);
9+
const rule = new Rule('/.*/', data, ctrl);
810
test('Should be equals', () => {
911
expect(rule.getData()).toMatchSnapshot();
1012
});
@@ -15,7 +17,7 @@ describe('Rule', () => {
1517

1618
describe('Create', () => {
1719
test.skip('addshape & remove', () => {
18-
const rule = new Rule('/.*/', data);
20+
const rule = new Rule('/.*/', data, ctrl);
1921
rule.addShapeMap(pattern);
2022
expect(rule.getShapeMaps().length).toBe(1);
2123
rule.removeShapeMap(0);
@@ -25,26 +27,26 @@ describe('Rule', () => {
2527

2628
describe('Match', () => {
2729
test('Match on one', () => {
28-
const rule = new Rule('/.*/', data);
30+
const rule = new Rule('/.*/', data, ctrl);
2931
rule.addShapeMap(pattern);
3032
const sm = rule.getShapeMap(0);
3133
sm.match('Toto');
3234
expect(sm.match('Toto')).toBeTruthy();
3335
});
3436

3537
test('Match on all', () => {
36-
const rule = new Rule('/.*/', data);
38+
const rule = new Rule('/.*/', data, ctrl);
3739
rule.addShapeMap(pattern);
3840
expect(rule.matchShape('Toto')).toBeTruthy();
3941
expect(rule.matchShape('Tata')).toBeFalsy();
4042
});
4143
});
4244

4345
describe('Colorize', () => {
44-
const rule = new Rule('/.*/', data);
46+
const rule = new Rule('/.*/', data, ctrl);
4547
// 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);
4850
const shape = rule.addShapeMap(pattern);
4951

5052
test('isEligible always ERR should be true', () => {
@@ -70,22 +72,22 @@ describe('Rule', () => {
7072
const pattern = '/.*Toto.*/';
7173

7274
test('addshape & remove', () => {
73-
const rule = new Rule('/.*/', data);
75+
const rule = new Rule('/.*/', data, ctrl);
7476
rule.addTextMap(pattern);
7577
expect(rule.getTextMaps().length).toBe(1);
7678
rule.removeTextMap(0);
7779
expect(rule.getTextMaps().length).toBe(0);
7880
});
7981

8082
test('Match on one', () => {
81-
const rule = new Rule('/.*/', data);
83+
const rule = new Rule('/.*/', data, ctrl);
8284
rule.addTextMap(pattern);
8385
const sm = rule.getTextMap(0);
8486
expect(sm.match('Toto')).toBeTruthy();
8587
});
8688

8789
test('Match on all', () => {
88-
const rule = new Rule('/.*/', data);
90+
const rule = new Rule('/.*/', data, ctrl);
8991
rule.addTextMap(pattern);
9092
expect(rule.matchText('Toto')).toBeTruthy();
9193
expect(rule.matchText('Tata')).toBeFalsy();
@@ -95,22 +97,22 @@ describe('Rule', () => {
9597
describe('Link', () => {
9698
const pattern = '/.*Toto.*/';
9799
test('addshape & remove', () => {
98-
const rule = new Rule('/.*/', data);
100+
const rule = new Rule('/.*/', data, ctrl);
99101
rule.addLinkMap(pattern);
100102
expect(rule.getLinkMaps().length).toBe(1);
101103
rule.removeLinkMap(0);
102104
expect(rule.getLinkMaps().length).toBe(0);
103105
});
104106

105107
test('Match on one', () => {
106-
const rule = new Rule('/.*/', data);
108+
const rule = new Rule('/.*/', data, ctrl);
107109
rule.addLinkMap(pattern);
108110
const sm = rule.getLinkMap(0);
109111
expect(sm.match('Toto')).toBeTruthy();
110112
});
111113

112114
test('Match on all', () => {
113-
const rule = new Rule('/.*/', data);
115+
const rule = new Rule('/.*/', data, ctrl);
114116
rule.addLinkMap(pattern);
115117
expect(rule.matchLink('Toto')).toBeTruthy();
116118
expect(rule.matchLink('Tata')).toBeFalsy();
@@ -119,7 +121,7 @@ describe('Rule', () => {
119121

120122
describe('ValueMap', () => {
121123
test('addshape & remove', () => {
122-
const rule = new Rule('/.*/', data);
124+
const rule = new Rule('/.*/', data, ctrl);
123125
rule.data.mappingType = 1;
124126
rule.addValueMap(1, 'This 1');
125127
expect(rule.getValueMaps().length).toBe(1);
@@ -128,7 +130,7 @@ describe('Rule', () => {
128130
});
129131

130132
test('Mapping values', () => {
131-
const rule = new Rule('/.*/', data);
133+
const rule = new Rule('/.*/', data, ctrl);
132134
rule.data.mappingType = 1;
133135
rule.data.type = 'string';
134136
rule.addValueMap(1, 'This 1');
@@ -141,7 +143,7 @@ describe('Rule', () => {
141143

142144
describe('RangeMap', () => {
143145
test('addshape & remove', () => {
144-
const rule = new Rule('/.*/', data);
146+
const rule = new Rule('/.*/', data, ctrl);
145147
rule.data.mappingType = 2;
146148
rule.data.type = 'string';
147149
rule.addRangeMap(0, 5, 'Between 0 and 5');
@@ -151,7 +153,7 @@ describe('Rule', () => {
151153
});
152154

153155
test('Mapping values', () => {
154-
const rule = new Rule('/.*/', data);
156+
const rule = new Rule('/.*/', data, ctrl);
155157
rule.data.mappingType = 2;
156158
rule.data.type = 'string';
157159
rule.addRangeMap(0, 5, 'Between 0 and 5');
@@ -162,7 +164,7 @@ describe('Rule', () => {
162164
});
163165

164166
test('Mapping values upper and lower', () => {
165-
const rule = new Rule('/.*/', data);
167+
const rule = new Rule('/.*/', data, ctrl);
166168
rule.data.mappingType = 2;
167169
rule.data.type = 'string';
168170
rule.addRangeMap(undefined, 33, 'Lower than 33');
@@ -176,7 +178,7 @@ describe('Rule', () => {
176178

177179
describe('Text replace', () => {
178180
const data = Rule.getDefaultData();
179-
const rule = new Rule('/.*/', data);
181+
const rule = new Rule('/.*/', data, ctrl);
180182
const text = 'This is my value';
181183
const patternText = '/value/';
182184
const formattedValue = '12.34';

0 commit comments

Comments
 (0)