Skip to content

Commit

Permalink
Fix the progress value to 2 decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
shachiniM committed May 13, 2024
1 parent 3688050 commit d55001b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default defineComponent({
setup: function(props) {
const progressPercentage = computed(() => {
if (props.progressValue > 0)
return `${Math.min(props.progressValue, 100)}%`;
return `${Math.min(Number(props.progressValue.toFixed(2)), 100)}%`;
return '0%';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('LinearProgress.vue', () => {

it('renders OXD LinearProgress with custom value', () => {
const wrapper = mount(LinearProgress, {
props: {progressValue: '60'},
props: {progressValue: 60},
});
expect(
wrapper.find('.oxd-linear-progress-inner').attributes('style'),
Expand Down Expand Up @@ -93,4 +93,22 @@ describe('LinearProgress.vue', () => {
'0%',
);
});

it('when the percentage value is having decimal values', () => {
const wrapper = mount(LinearProgress, {
props: {progressValue: 5.78, showPercentageValue: true},
});
expect(wrapper.find('.oxd-linear-progress-value').text()).toStrictEqual(
'5.78%',
);
});

it('when the percentage value is having decimal values than 2 decimals', () => {
const wrapper = mount(LinearProgress, {
props: {progressValue: 5.7893883, showPercentageValue: true},
});
expect(wrapper.find('.oxd-linear-progress-value').text()).toStrictEqual(
'5.79%',
);
});
});

0 comments on commit d55001b

Please sign in to comment.