This commit is contained in:
parent
0d51987d47
commit
e7f9984b4b
|
@ -28,6 +28,12 @@ export default class Controller extends Component {
|
|||
} else {
|
||||
cssClass = type;
|
||||
switch (type) {
|
||||
case 'number':
|
||||
if (Number.isInteger(value))
|
||||
text = value;
|
||||
else
|
||||
text = Math.round((value + Number.EPSILON) * 1000) / 1000;
|
||||
break;
|
||||
case 'boolean':
|
||||
text = value ? '✓' : '✗';
|
||||
cssClass = value ? 'true' : 'false';
|
||||
|
|
|
@ -75,5 +75,19 @@ describe('Component vnJsonValue', () => {
|
|||
expect(el.textContent).toEqual('2050');
|
||||
expect(el.className).toContain('json-number');
|
||||
});
|
||||
|
||||
it('should display number when value is decimal', () => {
|
||||
controller.value = 10.1;
|
||||
|
||||
expect(el.textContent).toEqual('10.1');
|
||||
expect(el.className).toContain('json-number');
|
||||
});
|
||||
|
||||
it('should display rounded number when value is decimal with lot of decimals', () => {
|
||||
controller.value = 10.124323234;
|
||||
|
||||
expect(el.textContent).toEqual('10.124');
|
||||
expect(el.className).toContain('json-number');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue