Skip to content

Commit

Permalink
FIO-7602 fixed submission data for 0s values
Browse files Browse the repository at this point in the history
  • Loading branch information
HannaKurban committed Dec 6, 2023
1 parent df69371 commit 4bd4085
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/components/radio/Radio.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ export default class RadioComponent extends ListComponent {
return value;
}

if (!isNaN(parseFloat(value)) && isFinite(value)) {
const isEquivalent = value.toString() === Number(value).toString();

if (!isNaN(parseFloat(value)) && isFinite(value) && isEquivalent) {
value = +value;
}
if (value === 'true') {
Expand Down
20 changes: 19 additions & 1 deletion src/components/radio/Radio.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
comp6,
comp7,
comp8,
comp9
comp9,
comp10
} from './fixtures';

describe('Radio Component', () => {
Expand Down Expand Up @@ -113,6 +114,23 @@ describe('Radio Component', () => {
});
});

it('Should set correct data for 0s values', (done) => {
Harness.testCreate(RadioComponent, comp10).then((component) => {
component.setValue('01');
component.redraw();

setTimeout(()=>{
assert.equal(component._data.radio, '01');
component.setValue(1);
component.redraw();
setTimeout(()=>{
assert.equal(component._data.radio, 1);
done();
}, 200);
}, 200);
});
});

it('Span should have correct text label', () => {
return Harness.testCreate(RadioComponent, comp1).then((component) => {
component.element.querySelectorAll('input').forEach((input) => {
Expand Down
21 changes: 21 additions & 0 deletions src/components/radio/fixtures/comp10.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
'label': 'Radio',
'optionsLabelPosition': 'right',
'inline': false,
'tableView': false,
'values': [
{
'label': '01',
'value': '01',
'shortcut': ''
},
{
'label': '1',
'value': '1',
'shortcut': ''
}
],
'key': 'radio',
'type': 'radio',
'input': true
};
3 changes: 2 additions & 1 deletion src/components/radio/fixtures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ import comp6 from './comp6';
import comp7 from './comp7';
import comp8 from './comp8';
import comp9 from './comp9';
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9 };
import comp10 from './comp10';
export { comp1, comp2, comp3, comp4, comp5, comp6, comp7, comp8, comp9, comp10 };

0 comments on commit 4bd4085

Please sign in to comment.