From d6d71810f9bbbe0a14732c95dd3d84aafe907575 Mon Sep 17 00:00:00 2001 From: Eli White Date: Tue, 30 Jul 2019 23:56:15 -0700 Subject: [PATCH] Update ComponentDescriptorH to test all fixtures Summary: This test didn't get updated to run over all the fixtures like the others Reviewed By: JoshuaGross Differential Revision: D16501494 fbshipit-source-id: 4a68d60819701a9de7f1da22a66ccf807cc4490f --- .../GenerateComponentDescriptorH-test.js | 86 +----- .../GenerateComponentDescriptorH-test.js.snap | 286 ++++++++++++++---- 2 files changed, 230 insertions(+), 142 deletions(-) diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js index 64b911abf1f..02133c76f90 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GenerateComponentDescriptorH-test.js @@ -11,85 +11,17 @@ 'use strict'; +const fixtures = require('../__test_fixtures__/fixtures.js'); const generator = require('../GenerateComponentDescriptorH.js'); -const { - ARRAY_PROPS, - BOOLEAN_PROP, - STRING_PROP, - INTEGER_PROPS, - FLOAT_PROPS, - COLOR_PROP, - IMAGE_PROP, - POINT_PROP, - MULTI_NATIVE_PROP, - ENUM_PROP, - EVENT_PROPS, - TWO_COMPONENTS_SAME_FILE, - TWO_COMPONENTS_DIFFERENT_FILES, -} = require('../__test_fixtures__/fixtures.js'); - describe('GenerateComponentDescriptorH', () => { - it('can generate a array props', () => { - expect(generator.generate('ARRAY_PROPS', ARRAY_PROPS)).toMatchSnapshot(); - }); + Object.keys(fixtures) + .sort() + .forEach(fixtureName => { + const fixture = fixtures[fixtureName]; - it('can generate a single boolean prop', () => { - expect(generator.generate('BOOLEAN_PROP', BOOLEAN_PROP)).toMatchSnapshot(); - }); - - it('can generate a single string prop', () => { - expect(generator.generate('STRING_PROPS', STRING_PROP)).toMatchSnapshot(); - }); - - it('can generate integer props', () => { - expect( - generator.generate('INTEGER_PROPS', INTEGER_PROPS), - ).toMatchSnapshot(); - }); - - it('can generate float props', () => { - expect(generator.generate('FLOAT_PROPS', FLOAT_PROPS)).toMatchSnapshot(); - }); - - it('can generate a single native primitive prop', () => { - expect(generator.generate('COLOR_PROP', COLOR_PROP)).toMatchSnapshot(); - }); - - it('can generate a native primitive image prop', () => { - expect(generator.generate('IMAGE_PROP', IMAGE_PROP)).toMatchSnapshot(); - }); - - it('can generate a native primitive point prop', () => { - expect(generator.generate('IMAGE_PROP', POINT_PROP)).toMatchSnapshot(); - }); - - it('can generate multiple native props', () => { - expect( - generator.generate('MULTI_NATIVE_PROP', MULTI_NATIVE_PROP), - ).toMatchSnapshot(); - }); - - it('can generate enum props', () => { - expect(generator.generate('ENUM_PROP', ENUM_PROP)).toMatchSnapshot(); - }); - - it('can generate events', () => { - expect(generator.generate('EVENT_PROPS', EVENT_PROPS)).toMatchSnapshot(); - }); - - it('supports two components from same module', () => { - expect( - generator.generate('TWO_COMPONENTS_SAME_FILE', TWO_COMPONENTS_SAME_FILE), - ).toMatchSnapshot(); - }); - - it('supports two components from different modules', () => { - expect( - generator.generate( - 'TWO_COMPONENTS_DIFFERENT_FILES', - TWO_COMPONENTS_DIFFERENT_FILES, - ), - ).toMatchSnapshot(); - }); + it(`can generate fixture ${fixtureName}`, () => { + expect(generator.generate(fixtureName, fixture)).toMatchSnapshot(); + }); + }); }); diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 6a46dea5fb2..2ad02997bd5 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`GenerateComponentDescriptorH can generate a array props 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture ARRAY_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -26,59 +26,7 @@ using ArrayPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor } `; -exports[`GenerateComponentDescriptorH can generate a native primitive image prop 1`] = ` -Map { - "ComponentDescriptors.h" => " -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -using ImagePropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; - -} // namespace react -} // namespace facebook -", -} -`; - -exports[`GenerateComponentDescriptorH can generate a native primitive point prop 1`] = ` -Map { - "ComponentDescriptors.h" => " -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -using PointPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; - -} // namespace react -} // namespace facebook -", -} -`; - -exports[`GenerateComponentDescriptorH can generate a single boolean prop 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture BOOLEAN_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -104,7 +52,7 @@ using BooleanPropNativeComponentComponentDescriptor = ConcreteComponentDescripto } `; -exports[`GenerateComponentDescriptorH can generate a single native primitive prop 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture COLOR_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -130,7 +78,7 @@ using ColorPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor< } `; -exports[`GenerateComponentDescriptorH can generate a single string prop 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture COMMANDS 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -142,13 +90,13 @@ Map { #pragma once -#include +#include #include namespace facebook { namespace react { -using StringPropComponentComponentDescriptor = ConcreteComponentDescriptor; +using CommandNativeComponentComponentDescriptor = ConcreteComponentDescriptor; } // namespace react } // namespace facebook @@ -156,7 +104,33 @@ using StringPropComponentComponentDescriptor = ConcreteComponentDescriptor " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using CommandNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture ENUM_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -182,7 +156,33 @@ using EnumPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor< } `; -exports[`GenerateComponentDescriptorH can generate events 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using EventsNestedObjectNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture EVENT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -208,7 +208,33 @@ using EventsNativeComponentComponentDescriptor = ConcreteComponentDescriptor " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture FLOAT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -234,7 +260,33 @@ using FloatPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor< } `; -exports[`GenerateComponentDescriptorH can generate integer props 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture IMAGE_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using ImagePropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture INTEGER_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -260,7 +312,33 @@ using IntegerPropNativeComponentComponentDescriptor = ConcreteComponentDescripto } `; -exports[`GenerateComponentDescriptorH can generate multiple native props 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture INTERFACE_ONLY 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + + + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture MULTI_NATIVE_PROP 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -286,7 +364,85 @@ using ImageColorPropNativeComponentComponentDescriptor = ConcreteComponentDescri } `; -exports[`GenerateComponentDescriptorH supports two components from different modules 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture NO_PROPS_NO_EVENTS 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using NoPropsNoEventsComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture POINT_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using PointPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture STRING_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using StringPropComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateComponentDescriptorH can generate fixture TWO_COMPONENTS_DIFFERENT_FILES 1`] = ` Map { "ComponentDescriptors.h" => " /** @@ -313,7 +469,7 @@ using MultiFile2NativeComponentComponentDescriptor = ConcreteComponentDescriptor } `; -exports[`GenerateComponentDescriptorH supports two components from same module 1`] = ` +exports[`GenerateComponentDescriptorH can generate fixture TWO_COMPONENTS_SAME_FILE 1`] = ` Map { "ComponentDescriptors.h" => " /**