Skip to content

Commit

Permalink
fix: import custom component from local directory (#182)
Browse files Browse the repository at this point in the history
Retain unofficial support of all primitives
  • Loading branch information
dpilch authored Nov 2, 2021
1 parent 1c49ac0 commit 5cd1076
Show file tree
Hide file tree
Showing 21 changed files with 940 additions and 126 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`Component Renderers CardRenderer 1`] = `"<Card {...rest} {...getOverrid

exports[`Component Renderers CollectionRenderer 1`] = `"<Collection items={items || []} {...rest} {...getOverrideProps(overrides, \\"Collection\\")}>{(item, index) => ()}</Collection>"`;

exports[`Component Renderers CustomComponentRenderer 1`] = `"<Custom {...findChildOverrides(props.overrides, \\"Custom\\")}></Custom>"`;
exports[`Component Renderers CustomComponentRenderer 1`] = `"<Custom {...rest} {...getOverrideProps(overrides, \\"Custom\\")}></Custom>"`;

exports[`Component Renderers DividerRenderer 1`] = `"<Divider {...rest} {...getOverrideProps(overrides, \\"Divider\\")}></Divider>"`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,78 @@ describe('amplify render tests', () => {
it('should render parsed fixed values', () => {
expect(generateWithAmplifyRenderer('parsedFixedValues')).toMatchSnapshot();
});

describe('custom components', () => {
describe('custom children', () => {
it('should render component with custom children', () => {
expect(generateWithAmplifyRenderer('custom/customChildren').componentText).toMatchSnapshot();
});

it('should render component with custom children with ES5', () => {
expect(
generateWithAmplifyRenderer('custom/customChildren', {
target: ScriptTarget.ES5,
script: ScriptKind.JS,
}).componentText,
).toMatchSnapshot();
});

it('should render declarations', () => {
expect(
generateWithAmplifyRenderer('custom/customChildren', {
script: ScriptKind.JS,
renderTypeDeclarations: true,
}).declaration,
).toMatchSnapshot();
});
});

describe('custom parent', () => {
it('should render component', () => {
expect(generateWithAmplifyRenderer('custom/customParent').componentText).toMatchSnapshot();
});

it('should render component with ES5', () => {
expect(
generateWithAmplifyRenderer('custom/customParent', {
target: ScriptTarget.ES5,
script: ScriptKind.JS,
}).componentText,
).toMatchSnapshot();
});

it('should render declarations', () => {
expect(
generateWithAmplifyRenderer('custom/customParent', {
script: ScriptKind.JS,
renderTypeDeclarations: true,
}).declaration,
).toMatchSnapshot();
});
});

describe('custom parent and children', () => {
it('should render component with custom parent and children', () => {
expect(generateWithAmplifyRenderer('custom/customParentAndChildren').componentText).toMatchSnapshot();
});

it('should render component with custom parent and children with ES5', () => {
expect(
generateWithAmplifyRenderer('custom/customParentAndChildren', {
target: ScriptTarget.ES5,
script: ScriptKind.JS,
}).componentText,
).toMatchSnapshot();
});

it('should render declarations', () => {
expect(
generateWithAmplifyRenderer('custom/customParentAndChildren', {
script: ScriptKind.JS,
renderTypeDeclarations: true,
}).declaration,
).toMatchSnapshot();
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "1234-5678-9010",
"componentType": "MyView",
"name": "CustomChildren",
"properties": {},
"children": [{
"componentType": "CustomButton",
"properties": {}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "1234-5678-9010",
"componentType": "MyView",
"name": "CustomParent",
"properties": {},
"children": [{
"componentType": "Button",
"properties": {}
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "1234-5678-9010",
"componentType": "ViewTest",
"name": "CustomParentAndChildren",
"properties": {},
"children": [{
"componentType": "CustomButton",
"properties": {}
}]
}
Loading

0 comments on commit 5cd1076

Please sign in to comment.