Skip to content

Commit

Permalink
Add broken fixture for objects with array props
Browse files Browse the repository at this point in the history
Summary: Adds a broken fixture for arrays nested inside of objects (fixed in the next diffs)

Reviewed By: TheSavior

Differential Revision: D16896138

fbshipit-source-id: 355a71352a78ca076c1de56304908e664772c200
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Aug 19, 2019
1 parent 3050ac2 commit 5f09a17
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,35 @@ const OBJECT_PROPS: SchemaType = {
],
},
},
{
name: 'nestedArrayAsProperty',
optional: false,
typeAnnotation: {
type: 'ObjectTypeAnnotation',
properties: [
{
name: 'arrayProp',
optional: false,
typeAnnotation: {
type: 'ArrayTypeAnnotation',
elementType: {
type: 'ObjectTypeAnnotation',
properties: [
{
name: 'stringProp',
optional: false,
typeAnnotation: {
type: 'StringTypeAnnotation',
default: '',
},
},
],
},
},
},
],
},
},
],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,23 @@ static inline std::string toString(const ObjectPropsObjectPropNestedPropAStruct
return \\"[Object ObjectPropsObjectPropNestedPropAStruct]\\";
}
struct ObjectPropsObjectPropNestedArrayAsPropertyStruct {
std::vector<ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct> arrayProp;
};
static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropNestedArrayAsPropertyStruct &result) {
auto map = (better::map<std::string, RawValue>)value;
auto arrayProp = map.find(\\"arrayProp\\");
if (arrayProp != map.end()) {
fromRawValue(arrayProp->second, result.arrayProp);
}
}
static inline std::string toString(const ObjectPropsObjectPropNestedArrayAsPropertyStruct &value) {
return \\"[Object ObjectPropsObjectPropNestedArrayAsPropertyStruct]\\";
}
struct ObjectPropsObjectPropStruct {
std::string stringProp;
bool booleanProp;
Expand All @@ -893,6 +910,7 @@ struct ObjectPropsObjectPropStruct {
ObjectPropsObjectPropObjectArrayPropStruct objectArrayProp;
ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct objectPrimitiveRequiredProp;
ObjectPropsObjectPropNestedPropAStruct nestedPropA;
ObjectPropsObjectPropNestedArrayAsPropertyStruct nestedArrayAsProperty;
};
static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropStruct &result) {
Expand Down Expand Up @@ -930,6 +948,10 @@ static inline void fromRawValue(const RawValue &value, ObjectPropsObjectPropStru
if (nestedPropA != map.end()) {
fromRawValue(nestedPropA->second, result.nestedPropA);
}
auto nestedArrayAsProperty = map.find(\\"nestedArrayAsProperty\\");
if (nestedArrayAsProperty != map.end()) {
fromRawValue(nestedArrayAsProperty->second, result.nestedArrayAsProperty);
}
}
static inline std::string toString(const ObjectPropsObjectPropStruct &value) {
Expand Down

0 comments on commit 5f09a17

Please sign in to comment.