import { render, fireEvent } from '@testing-library/vue'
import Component from './Component.vue'
test('properly handles v-model', async () => {
const { getByLabelText, getByText } = render(Component)
// Asserts initial state.
getByText('Hi, my name is Alice')
// Get the input DOM node by querying the associated label.
const usernameInput = getByLabelText(/username/i)
// Updates the <input> value and triggers an `input` event.
// fireEvent.input() would make the test fail.
await fireEvent.update(usernameInput, 'Bob')
getByText('Hi, my name is Bob')
})
const requiredProps = ['title', 'name', 'etc'];
validator: function (heroObj) {
// check to see if all the required props are passed in the object
return requiredProps.every(requiredValue => (
Object.entries(heroObj).some(([key, val]) => {
// double check to make sure the value isn't 'undefined'
return (requiredValue === key) && val;
})
));
},
Comments