Skip to content

Commit

Permalink
Make sure bug with useFlowReadOnlyTypes on Enums is fixed #1413
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela authored and dotansimha committed Mar 11, 2019
1 parent 8c4a495 commit 9a9a205
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions packages/plugins/flow/tests/flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@ describe('Flow Plugin', () => {
});

it('Should respect flow option useFlowReadOnlyTypes', () => {
const ast = parse(`
const ast = parse(/* GraphQL */ `
interface MyInterface {
foo: String
bar: String!
}`);
}
enum MyEnum {
A
B
C
}
`);
const result = visit(ast, {
leave: new FlowVisitor({
useFlowReadOnlyTypes: true
Expand All @@ -46,7 +53,17 @@ describe('Flow Plugin', () => {
+bar: string,
};
`);
expect(result.definitions[1]).toBeSimilarStringTo(`
export const MyEnumValues = Object.freeze({
A: 'A',
B: 'B',
C: 'C'
});
export type MyEnum = $Values<typeof MyEnumValues>;
`);

validateFlow(result.definitions[0]);
validateFlow(result.definitions[1]);
});
});

Expand Down

0 comments on commit 9a9a205

Please sign in to comment.