Skip to content
Snippets Groups Projects
Commit e842999c authored by Mohammad Nakhaee's avatar Mohammad Nakhaee
Browse files

Resolve "frontend float quantities validation"

Changelog: Fixed
parent 8194c0c1
No related branches found
No related tags found
1 merge request!2039Resolve "frontend float quantities validation"
......@@ -45,11 +45,13 @@ describe('Test numberEditQuantity', () => {
await waitFor(() => expect(numberFieldValueInput.value).toEqual('10'))
await changeValue(numberFieldValueInput, '5')
await changeValue(numberFieldValueInput, '0')
await changeValue(numberFieldValueInput, '')
await waitFor(() => expect(handleChange.mock.calls).toHaveLength(2))
await waitFor(() => expect(handleChange.mock.calls).toHaveLength(3))
await waitFor(() => expect(handleChange.mock.calls[0][0]).toBe(5))
await waitFor(() => expect(handleChange.mock.calls[1][0]).toBe(undefined))
await waitFor(() => expect(handleChange.mock.calls[1][0]).toBe(0))
await waitFor(() => expect(handleChange.mock.calls[2][0]).toBe(undefined))
})
test.each([
......
......@@ -16,7 +16,7 @@
* limitations under the License.
*/
import {memoize, has} from 'lodash'
import {memoize, has, isNil} from 'lodash'
import {Unit} from './Unit'
import { Unit as UnitMathJS } from 'mathjs'
......@@ -53,7 +53,7 @@ export function parse(input, options) {
try {
const parseResults = parseInternal(input, options)
result.value = parseResults.value || undefined
result.value = isNil(parseResults.value) ? undefined : parseResults.value
result.valueString = parseResults.valueString || undefined
if (parseResults.unit?.units?.length) {
result.unit = new Unit(parseResults.unit)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment