diff --git a/packages/core/strapi/lib/services/entity-service/__tests__/entity-service-events.test.js b/packages/core/strapi/lib/services/entity-service/__tests__/entity-service-events.test.js index a49315eaf9..dca0c8ffdd 100644 --- a/packages/core/strapi/lib/services/entity-service/__tests__/entity-service-events.test.js +++ b/packages/core/strapi/lib/services/entity-service/__tests__/entity-service-events.test.js @@ -3,11 +3,6 @@ const createEntityService = require('..'); const entityValidator = require('../../entity-validator'); -jest.mock('../components', () => ({ - ...jest.requireActual('../components'), - getComponents: jest.fn(), -})); - describe('Entity service triggers webhooks', () => { global.strapi = { getModel: () => ({}), diff --git a/packages/core/strapi/lib/services/entity-service/components.js b/packages/core/strapi/lib/services/entity-service/components.js index 359b5cdda1..17cd90c823 100644 --- a/packages/core/strapi/lib/services/entity-service/components.js +++ b/packages/core/strapi/lib/services/entity-service/components.js @@ -104,10 +104,12 @@ const createComponents = async (uid, data) => { /** * @param {str} uid * @param {object} entity - * @return {Promise<{uid: string, entity: object}[]>} + * @return {Promise<{uid: string, entity: object}>} */ const getComponents = async (uid, entity) => { const componentAttributes = getComponentAttributes(strapi.getModel(uid)); + + if (_.isEmpty(componentAttributes)) return {}; return strapi.query(uid).load(entity, componentAttributes); };