I'm using the following test to pass a value of 2 inside my vue component
const wrapper = factory({ value: 2 })
const input = wrapper.find('input[type=number]')
expect(input.element.value).toBe(2)
But the received is always a string, even though I'm passing it as an integer in the form input field This is the error message:
expect(received).toBe(expected) // Object.is equality
Expected: 2
Received: "2"
This is my vue code, which basically just sets the value. I have to allow String and Number, since my database can return either, hence the dynamic prop allowance.
<template>
<div class="form-group row">
<input
:value="value"
:min="min"
:max="max"
class="form-control"
type="number"
@input="$emit('input', $event.target.value)"
/>
</template>
<script>
export default {
props: {
value: {
type: [String, Number],
default: ''
},
}
}
</script>
Aucun commentaire:
Enregistrer un commentaire