Skip to content

Instantly share code, notes, and snippets.

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