Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

Simplify extension test #523

Merged
merged 1 commit into from
Jul 1, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions src/__tests__/http-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2111,24 +2111,16 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
it('allows for adding extensions', async () => {
const app = server();

const extensions = ({ context = {} }) => {
if (context !== null && typeof context.startTime === 'number') {
return {
runTime: 1000000010 /* Date.now() */ - context.startTime,
};
}

return {};
};

get(
app,
urlString(),
graphqlHTTP(() => {
return {
schema: TestSchema,
context: { startTime: 1000000000 },
extensions,
context: { foo: 'bar' },
extensions({ context }) {
return { contextValue: JSON.stringify(context) };
},
};
}),
);
Expand All @@ -2140,7 +2132,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
expect(response.status).to.equal(200);
expect(response.type).to.equal('application/json');
expect(response.text).to.equal(
'{"data":{"test":"Hello World"},"extensions":{"runTime":10}}',
'{"data":{"test":"Hello World"},"extensions":{"contextValue":"{\\"foo\\":\\"bar\\"}"}}',
);
});

Expand Down