Skip to content

Commit

Permalink
tests: test config with Ioc namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
stropitek committed Jan 9, 2024
1 parent 34033db commit 31d2710
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/__tests__/createApolloConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import createApolloConfig from '../createApolloConfig';

const testIoC = new Ioc();

class Formatter {
formatError() {
return {
message: 'error',
};
}
}
testIoC.singleton('App/Exceptions/GraphqlHandler', () => new Formatter());

describe('apollo config', () => {
it('create apollo configuration, formatError is callback', () => {
const config = createApolloConfig(
Expand Down Expand Up @@ -31,4 +40,31 @@ describe('apollo config', () => {
},
});
});

it('create apollo configuration, formatError is an IoC dependency', () => {
const config = createApolloConfig(
{
schemas: 'app/Schemas',
resolvers: 'app/Resolvers',
path: '/graphql',
apolloServer: {
introspection: true,
formatError: 'App/Exceptions/GraphqlHandler',
},
},
{
ioc: testIoC,
fallbackUrl: 'http://localhost:3333',
},
);
expect(config).toEqual({
schemas: 'app/Schemas',
resolvers: 'app/Resolvers',
path: '/graphql',
apolloServer: {
introspection: true,
formatError: expect.any(Function),
},
});
});
});

0 comments on commit 31d2710

Please sign in to comment.