Skip to content

Commit

Permalink
fix: speedcard value cutoff #141
Browse files Browse the repository at this point in the history
  • Loading branch information
WDaan committed Feb 15, 2021
1 parent d362aef commit a81b1ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/components/Core/SpeedCard.vue
Expand Up @@ -35,7 +35,7 @@ export default {
getSpeedValue(value) {
if (!value) return '0'
const c = 1024
const d = value > 1048576 ? 2 : 0 // 2 decimals when MB
const d = value > 1048576 ? 1 : 0 // 2 decimals when MB
const f = Math.floor(Math.log(value) / Math.log(c))
return `${parseFloat((value / Math.pow(c, f)).toFixed(d))}`
Expand All @@ -50,4 +50,4 @@ export default {
padding: 32px 16px !important;
font-size: 1.05em;
}
</style>
</style>
6 changes: 3 additions & 3 deletions tests/unit/SpeedCard.spec.js
Expand Up @@ -34,10 +34,10 @@ describe('SpeedCard.vue', () => {
expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('KB/s')
})

it('should render value (2 decimals) and unit & be formatted', () => {
it('should render value (1 decimals) and unit & be formatted', () => {
const wrapper = setup(SpeedCard, { value: 10899700 })
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('10.39')
expect(wrapper.find('[data-testid="SpeedCard-value"]').text()).toBe('10.4')

expect(wrapper.find('[data-testid="SpeedCard-unit"]').text()).toBe('MB/s')
})
})
})

0 comments on commit a81b1ea

Please sign in to comment.