Skip to content

Commit

Permalink
fix: use no-data translation in React Material array layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxouwell committed Feb 20, 2024
1 parent e3bddec commit 1d73eb7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const MaterialArrayLayoutComponent = (props: ArrayLayoutProps) => {
);
})
) : (
<p>No data</p>
<p>{translations.noDataMessage}</p>
)}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const data = [
message2: 'Yolo 2',
},
];

const emptyData: any[] = [];
const schema: JsonSchema7 = {
type: 'array',
items: {
Expand Down Expand Up @@ -610,4 +612,21 @@ describe('Material array layout', () => {
wrapper.find('.MuiToolbar-root .MuiFormHelperText-root').exists()
).toBeFalsy();
});

it('should have a translation for no data', () => {
const translate = () => 'Translated';
const core = initCore(schema, uischema, emptyData);
wrapper = mount(
<JsonFormsStateProvider
initState={{ renderers: materialRenderers, core, i18n: { translate } }}
>
<MaterialArrayLayout
schema={schema}
uischema={uischemaOptions.inline}
/>
</JsonFormsStateProvider>
);
const noDataLabel = wrapper.find('div>div>p').text();
expect(noDataLabel.includes('Translated')).toBeTruthy();
});
});

0 comments on commit 1d73eb7

Please sign in to comment.