Last active
November 25, 2020 18:10
-
-
Save vdsabev/299ca73693fb5087e343e6a0e14e23af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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