Skip to content

Instantly share code, notes, and snippets.

@dvallin
Created November 29, 2017 16:46
Show Gist options
  • Save dvallin/ff9381be7e2db50eb73cc821fee5ad8e to your computer and use it in GitHub Desktop.
Save dvallin/ff9381be7e2db50eb73cc821fee5ad8e to your computer and use it in GitHub Desktop.
import store from '../../src/store'
// ...
it('adds task from input field, if enter key is pressed', (done) => {
const spy = jest.spyOn(store, 'dispatch'); // 0
const givenValue = "A very special value";
const wrapper = mount(NewTaskInput, { store });
const input = wrapper.find('input');
input.element.value = givenValue; // 1
input.trigger('input'); // 2
input.trigger('keyup.enter'); // 3
wrapper.vm.$nextTick(() => { // 4
expect(spy).toHaveBeenCalledWith({
type: Actions.AddTask,
title: givenValue
});
done(); // 5
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment