mirror of
https://github.com/strapi/strapi.git
synced 2025-08-05 07:16:02 +00:00
check if there are no components
This commit is contained in:
parent
2200f279ab
commit
6f76aee4d7
@ -3,11 +3,6 @@
|
|||||||
const createEntityService = require('..');
|
const createEntityService = require('..');
|
||||||
const entityValidator = require('../../entity-validator');
|
const entityValidator = require('../../entity-validator');
|
||||||
|
|
||||||
jest.mock('../components', () => ({
|
|
||||||
...jest.requireActual('../components'),
|
|
||||||
getComponents: jest.fn(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
describe('Entity service triggers webhooks', () => {
|
describe('Entity service triggers webhooks', () => {
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
getModel: () => ({}),
|
getModel: () => ({}),
|
||||||
|
@ -104,10 +104,12 @@ const createComponents = async (uid, data) => {
|
|||||||
/**
|
/**
|
||||||
* @param {str} uid
|
* @param {str} uid
|
||||||
* @param {object} entity
|
* @param {object} entity
|
||||||
* @return {Promise<{uid: string, entity: object}[]>}
|
* @return {Promise<{uid: string, entity: object}>}
|
||||||
*/
|
*/
|
||||||
const getComponents = async (uid, entity) => {
|
const getComponents = async (uid, entity) => {
|
||||||
const componentAttributes = getComponentAttributes(strapi.getModel(uid));
|
const componentAttributes = getComponentAttributes(strapi.getModel(uid));
|
||||||
|
|
||||||
|
if (_.isEmpty(componentAttributes)) return {};
|
||||||
return strapi.query(uid).load(entity, componentAttributes);
|
return strapi.query(uid).load(entity, componentAttributes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user