|
| 1 | +import { colorTextBySeverity } from '../../../src/lib/snyk-test/common'; |
| 2 | +import { color } from '../../../src/lib/theme'; |
| 3 | +import { SEVERITY } from '../../../src/lib/snyk-test/common'; |
| 4 | + |
| 5 | +describe('colorTextBySeverity', () => { |
| 6 | + it('Returns a high severity colored text', () => { |
| 7 | + const severity = SEVERITY.HIGH; |
| 8 | + expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( |
| 9 | + color.severity[severity]('Pls help me'), |
| 10 | + ); |
| 11 | + }); |
| 12 | + |
| 13 | + it('Pass an empty string as text', () => { |
| 14 | + const severity = SEVERITY.HIGH; |
| 15 | + expect(colorTextBySeverity(severity, '')).toEqual( |
| 16 | + color.severity[severity](''), |
| 17 | + ); |
| 18 | + }); |
| 19 | + |
| 20 | + it('Pass an empty string as severity', () => { |
| 21 | + const severity = ''; |
| 22 | + const defaultSeverity = SEVERITY.LOW; |
| 23 | + expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( |
| 24 | + color.severity[defaultSeverity]('Pls help me'), |
| 25 | + ); |
| 26 | + }); |
| 27 | + |
| 28 | + it('Set defaultive low color when given a non existent severity', () => { |
| 29 | + const severity = 'nonExistentSeverity'; |
| 30 | + const defaultSeverity = SEVERITY.LOW; |
| 31 | + expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( |
| 32 | + color.severity[defaultSeverity]('Pls help me'), |
| 33 | + ); |
| 34 | + }); |
| 35 | + |
| 36 | + it('Pass an upper case string as severity', () => { |
| 37 | + const severity = 'HIGH'; |
| 38 | + const lowerCaseSeverity = SEVERITY.HIGH; |
| 39 | + expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( |
| 40 | + color.severity[lowerCaseSeverity]('Pls help me'), |
| 41 | + ); |
| 42 | + }); |
| 43 | +}); |
0 commit comments