mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
DynamicTable: Fix rendering of boolean fields
This commit is contained in:
parent
2edd2ae00c
commit
1b63360b41
@ -56,5 +56,9 @@ export default function hasContent(type, content, metadatas, fieldSchema) {
|
||||
return isNumber(content);
|
||||
}
|
||||
|
||||
if (type === 'boolean') {
|
||||
return content !== null;
|
||||
}
|
||||
|
||||
return !isEmpty(content);
|
||||
}
|
||||
|
@ -50,6 +50,23 @@ describe('hasContent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('boolean', () => {
|
||||
it('returns true if enabled', () => {
|
||||
const normalizedContent = hasContent('boolean', true);
|
||||
expect(normalizedContent).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns false if disabled', () => {
|
||||
const normalizedContent = hasContent('boolean', false);
|
||||
expect(normalizedContent).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns false for null', () => {
|
||||
const normalizedContent = hasContent('boolean', null);
|
||||
expect(normalizedContent).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ID', () => {
|
||||
it('returns true for id main fields', () => {
|
||||
const normalizedContent = hasContent('media', { id: 1 });
|
||||
|
Loading…
x
Reference in New Issue
Block a user