mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
refactor(upload)
This commit is contained in:
parent
1b39486f24
commit
4212f2d33a
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user