Skip to content

Commit

Permalink
Add test demonstrating HTTP headers extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
NSeydoux committed Nov 24, 2023
1 parent deae99f commit df9d6c9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions e2e/node/resource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,21 @@ describe("Authenticated end-to-end", () => {
// environments it reliably succeeds:
await expect(getWellKnownSolid(sessionResource)).resolves.not.toThrow();
});

it("can customize the fetch to access HTTP headers", async () => {
let headers: Headers = new Headers();
const customFetch: typeof fetch = async (
info: Parameters<typeof fetch>[0],
init?: Parameters<typeof fetch>[1],
) => {
const response = await fetchOptions.fetch(info, init);
if (info.toString() === sessionResource) {
headers = response.headers;
}
return response;
};
await getSolidDataset(sessionResource, { fetch: customFetch });

expect(headers.get("Content-Type")).toContain("text/turtle");
});
});

0 comments on commit df9d6c9

Please sign in to comment.