You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/runtime/samples/binding-input-number-2/_config.js

32 lines
804 B

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");
},
};