Skip to content

Commit ec55e51

Browse files
committed
subscription-test: use separate dummy query type
1 parent 513eacc commit ec55e51

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

src/subscription/__tests__/subscribe-test.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,18 @@ async function expectPromise(promise: Promise<mixed>) {
143143
};
144144
}
145145

146+
const DummyQueryType = new GraphQLObjectType({
147+
name: 'Query',
148+
fields: {
149+
dummy: { type: GraphQLString },
150+
},
151+
});
152+
146153
// Check all error cases when initializing the subscription.
147154
describe('Subscription Initialization Phase', () => {
148155
it('accepts multiple subscription fields defined in schema', async () => {
149156
const schema = new GraphQLSchema({
150-
query: QueryType,
157+
query: DummyQueryType,
151158
subscription: new GraphQLObjectType({
152159
name: 'Subscription',
153160
fields: {
@@ -183,7 +190,7 @@ describe('Subscription Initialization Phase', () => {
183190
}
184191

185192
const schema = new GraphQLSchema({
186-
query: QueryType,
193+
query: DummyQueryType,
187194
subscription: new GraphQLObjectType({
188195
name: 'Subscription',
189196
fields: {
@@ -216,7 +223,7 @@ describe('Subscription Initialization Phase', () => {
216223
}
217224

218225
const schema = new GraphQLSchema({
219-
query: QueryType,
226+
query: DummyQueryType,
220227
subscription: new GraphQLObjectType({
221228
name: 'Subscription',
222229
fields: {
@@ -255,7 +262,7 @@ describe('Subscription Initialization Phase', () => {
255262
let didResolveBar = false;
256263

257264
const schema = new GraphQLSchema({
258-
query: QueryType,
265+
query: DummyQueryType,
259266
subscription: new GraphQLObjectType({
260267
name: 'Subscription',
261268
fields: {
@@ -267,7 +274,7 @@ describe('Subscription Initialization Phase', () => {
267274
},
268275
},
269276
bar: {
270-
type: EmailEventType,
277+
type: GraphQLString,
271278
// istanbul ignore next (Shouldn't be called)
272279
subscribe() {
273280
didResolveBar = true;
@@ -295,7 +302,7 @@ describe('Subscription Initialization Phase', () => {
295302
it('throws an error if some of required arguments are missing', async () => {
296303
const document = parse('subscription { foo }');
297304
const schema = new GraphQLSchema({
298-
query: QueryType,
305+
query: DummyQueryType,
299306
subscription: new GraphQLObjectType({
300307
name: 'Subscription',
301308
fields: {
@@ -327,7 +334,7 @@ describe('Subscription Initialization Phase', () => {
327334

328335
it('resolves to an error for unknown subscription field', async () => {
329336
const schema = new GraphQLSchema({
330-
query: QueryType,
337+
query: DummyQueryType,
331338
subscription: new GraphQLObjectType({
332339
name: 'Subscription',
333340
fields: {
@@ -350,7 +357,7 @@ describe('Subscription Initialization Phase', () => {
350357

351358
it('should pass through unexpected errors thrown in subscribe', async () => {
352359
const schema = new GraphQLSchema({
353-
query: QueryType,
360+
query: DummyQueryType,
354361
subscription: new GraphQLObjectType({
355362
name: 'Subscription',
356363
fields: {
@@ -365,7 +372,7 @@ describe('Subscription Initialization Phase', () => {
365372

366373
it('throws an error if subscribe does not return an iterator', async () => {
367374
const schema = new GraphQLSchema({
368-
query: QueryType,
375+
query: DummyQueryType,
369376
subscription: new GraphQLObjectType({
370377
name: 'Subscription',
371378
fields: {
@@ -387,7 +394,7 @@ describe('Subscription Initialization Phase', () => {
387394
it('resolves to an error for subscription resolver errors', async () => {
388395
async function subscribeWithFn(subscribeFn: () => mixed) {
389396
const schema = new GraphQLSchema({
390-
query: QueryType,
397+
query: DummyQueryType,
391398
subscription: new GraphQLObjectType({
392399
name: 'Subscription',
393400
fields: {
@@ -439,7 +446,7 @@ describe('Subscription Initialization Phase', () => {
439446

440447
it('resolves to an error if variables were wrong type', async () => {
441448
const schema = new GraphQLSchema({
442-
query: QueryType,
449+
query: DummyQueryType,
443450
subscription: new GraphQLObjectType({
444451
name: 'Subscription',
445452
fields: {
@@ -853,7 +860,7 @@ describe('Subscription Publish Phase', () => {
853860
}
854861

855862
const schema = new GraphQLSchema({
856-
query: QueryType,
863+
query: DummyQueryType,
857864
subscription: new GraphQLObjectType({
858865
name: 'Subscription',
859866
fields: {
@@ -914,7 +921,7 @@ describe('Subscription Publish Phase', () => {
914921
}
915922

916923
const schema = new GraphQLSchema({
917-
query: QueryType,
924+
query: DummyQueryType,
918925
subscription: new GraphQLObjectType({
919926
name: 'Subscription',
920927
fields: {

0 commit comments

Comments
 (0)