Skip to content

Instantly share code, notes, and snippets.

@dvallin
Created November 29, 2017 16:46
Show Gist options
  • Save dvallin/7d765630ef5c16813775ab1a99c25a0c to your computer and use it in GitHub Desktop.
Save dvallin/7d765630ef5c16813775ab1a99c25a0c to your computer and use it in GitHub Desktop.
it("maps fetched tasks into response", () => {
const rawTask = {id: "some id", moreData: "garble garble", title: "title"};
const tasks = [rawTask];
axios.get.mockReturnValueOnce(Promise.resolve({data: tasks}));
const promise = TasksApi.fetchTasks();
promise.then(value => {
expect(value).toHaveLength(1);
expect(value[0]).toBeInstanceOf(Task);
expect(value[0]).toEqual(new Task(rawTask.id, rawTask.title))
});
return promise;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment