diff --git a/test/runtime/samples/input-bind-number.solo/_config.js b/test/runtime/samples/input-bind-number.solo/_config.js new file mode 100644 index 0000000000..a3510eb757 --- /dev/null +++ b/test/runtime/samples/input-bind-number.solo/_config.js @@ -0,0 +1,31 @@ +export default { + test({ assert, target, window, component }) { + const input = target.querySelector("input"); + const inputEvent = new window.InputEvent("input"); + assert.equal(component.value, 5); + assert.equal(input.value, "5"); + + input.value = "5."; + input.dispatchEvent(inputEvent); + + // input type number has value === "" if ends with dot/comma + assert.equal(component.value, undefined); + assert.equal(input.value, ""); + + input.value = "5.5"; + input.dispatchEvent(inputEvent); + + assert.equal(component.value, 5.5); + assert.equal(input.value, "5.5"); + + input.value = "5.50"; + input.dispatchEvent(inputEvent); + + assert.equal(component.value, 5.5); + assert.equal(input.value, "5.50"); + + component.value = 1; + assert.equal(component.value, 1); + assert.equal(input.value, "1"); + }, +}; diff --git a/test/runtime/samples/input-bind-number.solo/main.svelte b/test/runtime/samples/input-bind-number.solo/main.svelte new file mode 100644 index 0000000000..7957e33229 --- /dev/null +++ b/test/runtime/samples/input-bind-number.solo/main.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file