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

Commit

Permalink
Simplify extension test (#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored Jul 1, 2019
1 parent 396948f commit a56d694
Showing 1 changed file with 5 additions and 13 deletions.
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

0 comments on commit a56d694

Please sign in to comment.