Fix missing strapi global in entity service tests

Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
Alexandre Bodin 2020-10-01 17:17:05 +02:00
parent 8589848ce4
commit e44a3f212e
2 changed files with 10 additions and 0 deletions

View File

@ -5,6 +5,15 @@ const entityValidator = require('../entity-validator');
const { EventEmitter } = require('events');
describe('Entity service', () => {
global.strapi = {
getModel: jest.fn(() => {}),
config: {
get() {
return [];
},
},
};
describe('Find', () => {
test('Returns first element for single types', async () => {
const data = {

View File

@ -78,6 +78,7 @@ module.exports = ({ db, eventHub, entityValidator }) => ({
await this.uploadFiles(entry, files, { model });
entry = await this.findOne({ params: { id: entry.id } }, { model });
}
eventHub.emit(ENTRY_CREATE, {
model: modelDef.modelName,
entry: sanitizeEntity(entry, { model: modelDef }),