Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LAN 1191 : Fix the progress value to 2 decimals in LinearProgress component #779

Open
wants to merge 1 commit into
base: ent
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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%',
);
});
});
Loading