Skip to content

Commit a31b9fc

Browse files
committed
Tests added to gauge component and fixed wrong typography
1 parent 368b92d commit a31b9fc

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

public/rich-components/gauge.svg

Lines changed: 4 additions & 5 deletions
Loading

src/common/components/mock-components/front-rich-components/gauge/gauge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const Gauge = forwardRef<any, ShapeProps>((props, ref) => {
9898
y={center - fontSizeScaled / 2}
9999
width={center + 10}
100100
text={displayValue}
101-
fontFamily="Arial, sans-serif"
101+
fontFamily={BASIC_SHAPE.DEFAULT_FONT_FAMILY}
102102
fontSize={fontSizeScaled}
103103
align="center"
104104
fill={textColor}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import {
2+
extractNumbersAsTwoDigitString,
3+
endsWhithPercentageSymbol,
4+
} from './gauge.utils';
5+
6+
describe('extractNumersAsTwoDigitString', () => {
7+
it('should return 0 when input contains no numbers', () => {
8+
const input = 'abc';
9+
const result = extractNumbersAsTwoDigitString(input);
10+
expect(result).toBe('0');
11+
});
12+
it('should return 100 when input is 100', () => {
13+
const input = '100';
14+
const result = extractNumbersAsTwoDigitString(input);
15+
expect(result).toBe('100');
16+
});
17+
it('should return one number when input is one number', () => {
18+
const input = '1';
19+
const result = extractNumbersAsTwoDigitString(input);
20+
expect(result).toBe('1');
21+
});
22+
it('should return two numbers when input is two numbers', () => {
23+
const input = '12';
24+
const result = extractNumbersAsTwoDigitString(input);
25+
expect(result).toBe('12');
26+
});
27+
28+
it('should return two first numbers when input contains different characters', () => {
29+
const input = 'abc123de$f';
30+
const result = extractNumbersAsTwoDigitString(input);
31+
expect(result).toBe('12');
32+
});
33+
});
34+
35+
describe('endsWhithPercentageSymbol', () => {
36+
it('should return false when input does not end with %', () => {
37+
const input = '%abc';
38+
const result = endsWhithPercentageSymbol(input);
39+
expect(result).toBe(false);
40+
});
41+
it('should return true when input ends with %', () => {
42+
const input = 'abc%';
43+
const result = endsWhithPercentageSymbol(input);
44+
expect(result).toBe(true);
45+
});
46+
});

0 commit comments

Comments
 (0)