Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import custom component from local directory #182

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

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