Skip to content

Commit

Permalink
add sofa.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
rhino88 committed Dec 4, 2023
1 parent 58d1e93 commit c7ff0e9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/plugins/sofa/src/__tests__/sofa.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { createSchema, createYoga } from 'graphql-yoga';
import { useSofa } from '@graphql-yoga/plugin-sofa';

const schema = createSchema({
typeDefs: /* GraphQL */ `
type Query {
_: String
}
`,
resolvers: {
Query: {
_: () => 'DUMMY',
},
},
});

it('should be able to invoke graphql query w/ plugin active', async () => {
const yoga = createYoga({
schema,
plugins: [
useSofa({
basePath: "/rest",
swaggerUI: {
endpoint: "/swagger",
},
}),
],
});
const response = await yoga.fetch('http://localhost:3000/graphql', {
method: 'POST',
headers: {
'content-type': 'application/json',
},
body: JSON.stringify({ query: '{ _ }' }),
});

expect(response.status).toEqual(200);
const body = await response.json();
expect(body).toEqual({
data: {
_: 'DUMMY',
},
});
});

0 comments on commit c7ff0e9

Please sign in to comment.