forked from Codility/viz-multiple_value-marketplace
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(bug): comparison as value change returns blank page b/342265977 (#41
- Loading branch information
1 parent
a191d76
commit 1703572
Showing
8 changed files
with
74 additions
and
33 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,15 @@ | ||
/** | ||
* Functions to get percentages and value changes in comparison points | ||
*/ | ||
|
||
export const getProgressPerc = (dataPoint, compDataPoint) => { | ||
return Math.round((dataPoint.value / compDataPoint?.value) * 100); | ||
}; | ||
|
||
export const getPercChange = progressPerc => { | ||
return progressPerc - 100; | ||
}; | ||
|
||
export const getValueChange = (dataPoint, compDataPoint) => { | ||
return dataPoint.value - compDataPoint?.value; | ||
}; |
File renamed without changes.
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
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
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
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,29 @@ | ||
import { | ||
getProgressPerc, | ||
getPercChange, | ||
getValueChange, | ||
} from '../lib/comparison_data_point'; | ||
|
||
const dataPoint = {value: 100}; | ||
const compDataPoint = {value: 20}; | ||
let progressPerc; | ||
|
||
describe('getProgressPerc', () => { | ||
test('should get correct percentage', () => { | ||
expect((progressPerc = getProgressPerc(dataPoint, compDataPoint))).toEqual( | ||
'500' | ||
); | ||
}); | ||
}); | ||
|
||
describe('getPercChange', () => { | ||
test('should get correct percentage', () => { | ||
expect(getPercChange(progressPerc)).toEqual('400'); | ||
}); | ||
}); | ||
|
||
describe('getValueChange', () => { | ||
test('should get correct value', () => { | ||
expect(getValueChange(dataPoint, compDataPoint)).toEqual('80'); | ||
}); | ||
}); |