Skip to content

Commit

Permalink
feat(cli-plugin-scaffold-graphql-service): add positive listBooks test
Browse files Browse the repository at this point in the history
  • Loading branch information
Fsalker committed May 20, 2020
1 parent 7e01e3c commit 9633bb6
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,33 @@ describe("Scaffold GraphQL service test", () => {
book = response.data.books.createBook.data;
});

test("List books (1 book)", async () => {
const query = /* GraphQL */ `
query {
books {
listBooks {
data {
id
title
createdOn
}
}
}
}
`;

const { schema, context } = await useSchema();
const response = await graphql(schema, query, {}, context);

if (response.errors) {
throw response.errors;
}
expect(response.data.books.listBooks.data.length).toEqual(1);
expect(response.data.books.listBooks.data[0]).toMatchObject({
title: bookName
});
});

test("Update book", async () => {
const query = /* GraphQL */ `
mutation updateBook($title: String!, $bookId: ID!) {
Expand Down

0 comments on commit 9633bb6

Please sign in to comment.