From d7b93d76db5c43dac04d3f9ffd2471a261a4d909 Mon Sep 17 00:00:00 2001 From: atanasster Date: Mon, 17 Aug 2020 09:21:16 +0300 Subject: [PATCH] fix: randomize number --- core/core/src/controls-randomize.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/core/src/controls-randomize.ts b/core/core/src/controls-randomize.ts index dc56e6d21..9ef25fe78 100644 --- a/core/core/src/controls-randomize.ts +++ b/core/core/src/controls-randomize.ts @@ -89,19 +89,18 @@ export const randomizeData = (controls: ComponentControls): RandomizedData => { value: faker.random.boolean(), }; case ControlTypes.NUMBER: - const step: number = control - ? (control as ComponentControlNumber).step || 1 - : 1; - + const step: number = (control as ComponentControlNumber)?.step || 1; const randomNumber: number = Math.max( Math.min( faker.random.number({ min: - (control as ComponentControlNumber).min || - (control.value as number) / 2, + (control as ComponentControlNumber).min || control.value + ? (control.value as number) / 2 + : 0, max: - (control as ComponentControlNumber).max || - (control.value as number) * 2, + (control as ComponentControlNumber).max || control.value + ? (control.value as number) * 2 + : 1, }), (control as ComponentControlNumber).max || Infinity, ),