From 9a9a20599f857f2a7c40ac29ec5020aa4b710926 Mon Sep 17 00:00:00 2001 From: Kamil Kisiela Date: Wed, 6 Mar 2019 11:08:46 +0100 Subject: [PATCH] Make sure bug with useFlowReadOnlyTypes on Enums is fixed #1413 --- packages/plugins/flow/tests/flow.spec.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/plugins/flow/tests/flow.spec.ts b/packages/plugins/flow/tests/flow.spec.ts index 282a5a5b94f..2341c819e9f 100644 --- a/packages/plugins/flow/tests/flow.spec.ts +++ b/packages/plugins/flow/tests/flow.spec.ts @@ -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 @@ -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; + `); + validateFlow(result.definitions[0]); + validateFlow(result.definitions[1]); }); });