Skip to content

Instantly share code, notes, and snippets.

@vdsabev
Last active November 25, 2020 18:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vdsabev/299ca73693fb5087e343e6a0e14e23af to your computer and use it in GitHub Desktop.
Save vdsabev/299ca73693fb5087e343e6a0e14e23af to your computer and use it in GitHub Desktop.
import { mount } from '@vue/test-utils';
import Counter from './Counter';
describe('Counter', () => {
let component;
beforeEach(() => {
component = mount(Counter);
});
it('should emit value set to a specific number', async () => {
const input = component.find('input'); // find the input
input.element.value = '5'; // set the input value
await input.trigger('input'); // trigger an `input` event
expect(component.emitted('input')).toEqual([[5]]);
});
it('should emit value incremented by step', async () => {
await component.setProps({ step: 10 });
await component.find('[aria-label="Decrement"]').trigger('click'); // find+click the button
expect(component.emitted('input')).toEqual([[10]]);
});
it('should emit value decremented by step', async () => {
await component.setProps({ step: 10 });
await component.find('[aria-label="Increment"]').trigger('click'); // find+click the button
expect(component.emitted('input')).toEqual([[-10]]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment