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

Commit a56d694

Browse files
Simplify extension test (#523)
1 parent 396948f commit a56d694

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/__tests__/http-test.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,24 +2111,16 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
21112111
it('allows for adding extensions', async () => {
21122112
const app = server();
21132113

2114-
const extensions = ({ context = {} }) => {
2115-
if (context !== null && typeof context.startTime === 'number') {
2116-
return {
2117-
runTime: 1000000010 /* Date.now() */ - context.startTime,
2118-
};
2119-
}
2120-
2121-
return {};
2122-
};
2123-
21242114
get(
21252115
app,
21262116
urlString(),
21272117
graphqlHTTP(() => {
21282118
return {
21292119
schema: TestSchema,
2130-
context: { startTime: 1000000000 },
2131-
extensions,
2120+
context: { foo: 'bar' },
2121+
extensions({ context }) {
2122+
return { contextValue: JSON.stringify(context) };
2123+
},
21322124
};
21332125
}),
21342126
);
@@ -2140,7 +2132,7 @@ function urlString(urlParams?: ?{ [param: string]: mixed, ... }) {
21402132
expect(response.status).to.equal(200);
21412133
expect(response.type).to.equal('application/json');
21422134
expect(response.text).to.equal(
2143-
'{"data":{"test":"Hello World"},"extensions":{"runTime":10}}',
2135+
'{"data":{"test":"Hello World"},"extensions":{"contextValue":"{\\"foo\\":\\"bar\\"}"}}',
21442136
);
21452137
});
21462138

0 commit comments

Comments
 (0)