Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flow): add flowtype tests #67

Merged
merged 1 commit into from
Feb 11, 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
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);