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

usage-test: enable Flow check #542

Merged
merged 1 commit into from
Jul 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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