-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
8 additions
and
50 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
30 changes: 3 additions & 27 deletions
30
web/src/features/psuInsights/components/map/psuFeatureStylers.test.ts
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 |
---|---|---|
@@ -1,38 +1,14 @@ | ||
import { getColorForRasterValue, setTransparency } from '@/features/psuInsights/components/map/psuFeatureStylers' | ||
|
||
describe('setTransparency', () => { | ||
it('should return an rgba value from rgb with correct alpha value', () => { | ||
const rgb = 'rgb(1, 1, 1)' | ||
const rgba = setTransparency(rgb, 0.5) | ||
expect(rgba).toBe('rgba(1, 1, 1, 0.5)') | ||
}) | ||
|
||
it('should return an updated rgba value from an rgba input', () => { | ||
const rgb = 'rgb(1, 1, 1, 1)' | ||
const rgba = setTransparency(rgb, 0.5) | ||
expect(rgba).toBe('rgba(1, 1, 1, 0.5)') | ||
}) | ||
|
||
it('should throw an error if fewer than 3 RGB values are provided', () => { | ||
const incompleteColor = 'rgb(1, 2)' | ||
expect(() => setTransparency(incompleteColor, 0.5)).toThrow(Error) | ||
}) | ||
|
||
it('should return a completely transparent colour if no colour is provided as input', () => { | ||
const rgba = setTransparency(undefined, 0.5) | ||
expect(rgba).toBe('rgba(0, 0, 0, 0)') | ||
}) | ||
}) | ||
import { getColorForRasterValue } from '@/features/psuInsights/components/map/psuFeatureStylers' | ||
|
||
describe('getColorForRasterValue', () => { | ||
it('should get the correct colour for the specified raster value', () => { | ||
const rasterValue = 1 | ||
const colour = getColorForRasterValue(rasterValue) | ||
expect(colour).toBe('rgb(209, 255, 115)') | ||
}) | ||
it('should return undefined if no colour is found', () => { | ||
it('should return a transparent colour if no colour is found', () => { | ||
const rasterValue = 1000 | ||
const colour = getColorForRasterValue(rasterValue) | ||
expect(colour).toBe(undefined) | ||
expect(colour).toBe('rgba(0, 0, 0, 0)') | ||
}) | ||
}) |
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