Skip to content

Commit

Permalink
fix(flow): add flowtype tests (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
evenchange4 authored Feb 11, 2019
1 parent 912ace6 commit 74cebd3
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
[lints]

[options]
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe

[strict]
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "NODE_ENV='test' jest --coverage",
"test:watch": "npm run test -- --watch",
"flow": "flow",
"flow-coverage": "hsu-scripts flow --threshold 66",
"flow-coverage": "hsu-scripts flow --threshold 71",
"eslint": "eslint ./",
"format": "prettier --write '**/*.{js,json,md,css,yaml,yml}' '*.{js,json,md,css,yaml,yml}'",
"changelog": "conventional-changelog --infile ./CHANGELOG.md --same-file --release-count 0 --output-unreleased"
Expand Down Expand Up @@ -48,7 +48,8 @@
"testPathIgnorePatterns": [
"<rootDir>/node_modules/",
"<rootDir>/lib/",
"<rootDir>/es/"
"<rootDir>/es/",
"<rootDir>/src/__tests__/flow.test.js"
],
"resetMocks": true,
"resetModules": true
Expand Down
29 changes: 29 additions & 0 deletions src/__tests__/flow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @flow
import { loader, gql } from '../index';

// $FlowFixMe number [1] is incompatible with string
export const loaderWithNumber = loader(3);
export const loaderWithString = loader('./fixtures/query3.graphql');

export const PostFragment = gql`
fragment Post on PostType {
title
date
}
`;
export const queryWithFragment = gql`
query User {
posts(id: 5) {
lastName
...PostFragment
}
}
${PostFragment}
`;
export const queryWithoutFragment = gql`
query User {
posts(id: 5) {
lastName
}
}
`;
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export type TemplateStringsArray = $ReadOnlyArray<string>;
export const loader = (filePath: string): DocumentNode => ({}: DocumentNode);
export const gql = (
taggedTemplateLiteral: TemplateStringsArray,
...placeholders: any[]
): DocumentNode => ({}: DocumentNode);

0 comments on commit 74cebd3

Please sign in to comment.