-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2121 from snyk/test/color-text-by-severity-test
test: colorTextBySeverity tests
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { colorTextBySeverity } from '../../../src/lib/snyk-test/common'; | ||
import { color } from '../../../src/lib/theme'; | ||
import { SEVERITY } from '../../../src/lib/snyk-test/common'; | ||
|
||
describe('colorTextBySeverity', () => { | ||
it('Returns a high severity colored text', () => { | ||
const severity = SEVERITY.HIGH; | ||
expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( | ||
color.severity[severity]('Pls help me'), | ||
); | ||
}); | ||
|
||
it('Pass an empty string as text', () => { | ||
const severity = SEVERITY.HIGH; | ||
expect(colorTextBySeverity(severity, '')).toEqual( | ||
color.severity[severity](''), | ||
); | ||
}); | ||
|
||
it('Pass an empty string as severity', () => { | ||
const severity = ''; | ||
const defaultSeverity = SEVERITY.LOW; | ||
expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( | ||
color.severity[defaultSeverity]('Pls help me'), | ||
); | ||
}); | ||
|
||
it('Set defaultive low color when given a non existent severity', () => { | ||
const severity = 'nonExistentSeverity'; | ||
const defaultSeverity = SEVERITY.LOW; | ||
expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( | ||
color.severity[defaultSeverity]('Pls help me'), | ||
); | ||
}); | ||
|
||
it('Pass an upper case string as severity', () => { | ||
const severity = 'HIGH'; | ||
const lowerCaseSeverity = SEVERITY.HIGH; | ||
expect(colorTextBySeverity(severity, 'Pls help me')).toEqual( | ||
color.severity[lowerCaseSeverity]('Pls help me'), | ||
); | ||
}); | ||
}); |