diff --git a/packages/core/upload/server/services/extensions/content-manager/__tests__/entity-manager.test.js b/packages/core/upload/server/services/extensions/content-manager/__tests__/entity-manager.test.js index 4b442a280d..03070a4921 100644 --- a/packages/core/upload/server/services/extensions/content-manager/__tests__/entity-manager.test.js +++ b/packages/core/upload/server/services/extensions/content-manager/__tests__/entity-manager.test.js @@ -65,7 +65,13 @@ describe('Upload | extensions | entity-manager', () => { })); describe('signEntityMedia', () => { - beforeAll(() => { + let spySignFileUrls; + beforeEach(() => { + spySignFileUrls = jest.fn(); + getService.mockImplementation(() => ({ + signFileUrls: spySignFileUrls, + })); + global.strapi = { plugins: { upload: {}, @@ -79,11 +85,6 @@ describe('Upload | extensions | entity-manager', () => { media: media[0], }; - const spySignFileUrls = jest.fn(); - getService.mockImplementation(() => ({ - signFileUrls: spySignFileUrls, - })); - await signEntityMedia(entity, modelUID); expect(getService).toBeCalledWith('file'); expect(spySignFileUrls).toBeCalledWith(entity.media); @@ -94,11 +95,6 @@ describe('Upload | extensions | entity-manager', () => { media_repeatable: media, }; - const spySignFileUrls = jest.fn(); - getService.mockImplementation(() => ({ - signFileUrls: spySignFileUrls, - })); - await signEntityMedia(entity, modelUID); expect(getService).toBeCalledWith('file'); expect(spySignFileUrls).toBeCalledTimes(2); @@ -116,11 +112,6 @@ describe('Upload | extensions | entity-manager', () => { }, }; - const spySignFileUrls = jest.fn(); - getService.mockImplementation(() => ({ - signFileUrls: spySignFileUrls, - })); - await signEntityMedia(entity, modelUID); expect(getService).toBeCalledWith('file'); expect(spySignFileUrls).toBeCalledTimes(3); @@ -141,11 +132,6 @@ describe('Upload | extensions | entity-manager', () => { ], }; - const spySignFileUrls = jest.fn(); - getService.mockImplementation(() => ({ - signFileUrls: spySignFileUrls, - })); - await signEntityMedia(entity, modelUID); expect(getService).toBeCalledWith('file'); expect(spySignFileUrls).toBeCalledTimes(6);