Merge pull request #1 from Boegie19/i18n-entity-service-wrapParams

I18n entity service wrap params
This commit is contained in:
Boegie19 2023-04-26 11:40:11 +02:00 committed by GitHub
commit 8b6cad699b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -45,6 +45,8 @@ const models = {
'localized-single-type-model': singleTypeModel,
};
const testModels = [['test-model'], ['non-localized-model'], ['localized-single-type-model']];
describe('Entity service decorator', () => {
beforeAll(() => {
global.strapi = {
@ -139,6 +141,16 @@ describe('Entity service decorator', () => {
['delete', { filters: [{ id: { $in: [1] } }] }],
];
test.each(testModels)('Always uses original wrapParams in output - %s', async (modelName) => {
const defaultService = {
wrapParams: jest.fn(() => Promise.resolve({ Test: 'Test' })),
};
const service = decorator(defaultService);
const output = await service.wrapParams({}, { uid: modelName, action: 'findMany' });
expect(output.Test).toEqual('Test');
});
test.each(testData)(
"Doesn't add locale param when the params contain id or id_in - %s",
async (action, params) => {