Skip to content

Commit

Permalink
usage-test: enable Flow check (graphql#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored and jliu670 committed Aug 14, 2020
1 parent 4c4a7ef commit 307fef9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ unnecessary-invariant=error
[options]
include_warnings=true
module.use_strict=true
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$DisableFlowOnNegativeTest

[version]
^0.102.0
8 changes: 8 additions & 0 deletions src/__tests__/usage-test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @flow strict

import { expect } from 'chai';
import { describe, it } from 'mocha';
import request from 'supertest';
Expand All @@ -8,13 +10,15 @@ import graphqlHTTP from '../';
describe('Useful errors when incorrectly used', () => {
it('requires an option factory function', () => {
expect(() => {
// $DisableFlowOnNegativeTest
graphqlHTTP();
}).to.throw('GraphQL middleware requires options.');
});

it('requires option factory function to return object', async () => {
const app = express();

// $DisableFlowOnNegativeTest
app.use('/graphql', graphqlHTTP(() => null));

const response = await request(app).get('/graphql?query={test}');
Expand All @@ -33,6 +37,7 @@ describe('Useful errors when incorrectly used', () => {
it('requires option factory function to return object or promise of object', async () => {
const app = express();

// $DisableFlowOnNegativeTest
app.use('/graphql', graphqlHTTP(() => Promise.resolve(null)));

const response = await request(app).get('/graphql?query={test}');
Expand All @@ -51,6 +56,7 @@ describe('Useful errors when incorrectly used', () => {
it('requires option factory function to return object with schema', async () => {
const app = express();

// $DisableFlowOnNegativeTest
app.use('/graphql', graphqlHTTP(() => ({})));

const response = await request(app).get('/graphql?query={test}');
Expand All @@ -66,6 +72,7 @@ describe('Useful errors when incorrectly used', () => {
it('requires option factory function to return object or promise of object with schema', async () => {
const app = express();

// $DisableFlowOnNegativeTest
app.use('/graphql', graphqlHTTP(() => Promise.resolve({})));

const response = await request(app).get('/graphql?query={test}');
Expand All @@ -79,6 +86,7 @@ describe('Useful errors when incorrectly used', () => {
});

it('validates schema before executing request', async () => {
// $DisableFlowOnNegativeTest
const schema = new GraphQLSchema({ directives: [null] });

const app = express();
Expand Down

0 comments on commit 307fef9

Please sign in to comment.