Skip to content

Commit

Permalink
Simplify extension test (graphql#523)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored and jliu670 committed Aug 14, 2020
1 parent 29434ae commit 96af8eb
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 96af8eb

Please sign in to comment.