Skip to content

Commit

Permalink
Added Graphql tests
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverGeneser committed Nov 1, 2023
1 parent db3ac4a commit 3fdfc47
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion servers/lib/test/e2e/app.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import {
expectedFileContentResponse,
expectedListDirectoryResponse,
} from "../testUtil";
import { ApolloClient, InMemoryCache, gql } from "@apollo/client";

const client = new ApolloClient({
uri: `http://localhost:4001${process.env.APOLLO_PATH}`,
cache: new InMemoryCache({addTypename:false})
});

describe("End to End test for the application", () => {
let app: INestApplication;
Expand Down Expand Up @@ -41,14 +47,29 @@ describe("End to End test for the application", () => {
expect(response.body).toEqual(expectedListDirectoryResponse);
}, 10000);

it("should return the content of a file given in the query ", async () => {
it("should return the filename corresponding to the directory given in the query |GraphQL|", async () => {
const query = gql(e2elistDirectory);

const {data} = await client.query({query});
expect({data}).toEqual(expectedListDirectoryResponse);
}, 10000);

it("should return the content of a file given in the query", async () => {
const query = e2eReadFile;

const response = await request("http://localhost:4001")
.post(process.env.APOLLO_PATH)
.send({ query });
expect(response.body).toEqual(expectedFileContentResponse);
}, 10000);

it("should return the content of a file given in the query |GraphQL|", async () => {
const query = gql(e2eReadFile);

const {data} = await client.query({query})
expect({data}).toEqual(expectedFileContentResponse);
}, 10000);

});

/*
Expand Down

0 comments on commit 3fdfc47

Please sign in to comment.