Skip to content

Commit

Permalink
fix(react): use default values correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jrea committed Jan 25, 2023
1 parent 4f4f7ee commit d020b40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react/src/lib/SimpleForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getAttributeDefault = (
return [String(attribute.defaultValue)];
}
}
return '';
return attribute.defaultValue ?? '';
};

export default function ConfigForm(props: {
Expand Down
1 change: 1 addition & 0 deletions packages/react/stories/EntityForm.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const customFieldAttributes = [
name: 'environment',
label: 'Environment',
type: AttributeType.Select,
defaultValue: 'test',
options: [
{ label: 'Test', value: 'test' },
{ label: 'Development', value: 'dev' },
Expand Down
8 changes: 8 additions & 0 deletions packages/react/test/lib/SimpleForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ describe('simple form', () => {
};
expect(getAttributeDefault(attribute)).toEqual(['gcp']);
});
it('maps default values for not a checkbox', () => {
const attribute: Attribute = {
name: 'cloud',
type: AttributeType.Select,
defaultValue: 'gcp',
};
expect(getAttributeDefault(attribute)).toEqual('gcp');
});
});

2 comments on commit d020b40

@vercel
Copy link

@vercel vercel bot commented on d020b40 Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d020b40 Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nile-js – ./

nile-js.vercel.app
nile-js-theniledev.vercel.app
nile-js-git-master-theniledev.vercel.app

Please sign in to comment.