|
| 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