diff --git a/gui/src/components/editQuantity/NumberEditQuantity.spec.js b/gui/src/components/editQuantity/NumberEditQuantity.spec.js index 6479defbef3b6847ecc290c3a6e811b6f665b427..5658da36fbb2c0207a992dc62650169c0d44217f 100644 --- a/gui/src/components/editQuantity/NumberEditQuantity.spec.js +++ b/gui/src/components/editQuantity/NumberEditQuantity.spec.js @@ -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([ diff --git a/gui/src/components/units/common.js b/gui/src/components/units/common.js index e0a6e46b56c29c2c0688862b54421b2d4ec152ce..a86474709431773b8bc967d516c29d08f59d7ff8 100644 --- a/gui/src/components/units/common.js +++ b/gui/src/components/units/common.js @@ -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)