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

FIO-7602 fixed submission data for 0s values #5423

Merged
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
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 };
Loading