mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 16:52:18 +00:00
refactor(upload)
This commit is contained in:
parent
1b39486f24
commit
4212f2d33a
@ -65,7 +65,13 @@ describe('Upload | extensions | entity-manager', () => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe('signEntityMedia', () => {
|
describe('signEntityMedia', () => {
|
||||||
beforeAll(() => {
|
let spySignFileUrls;
|
||||||
|
beforeEach(() => {
|
||||||
|
spySignFileUrls = jest.fn();
|
||||||
|
getService.mockImplementation(() => ({
|
||||||
|
signFileUrls: spySignFileUrls,
|
||||||
|
}));
|
||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
plugins: {
|
plugins: {
|
||||||
upload: {},
|
upload: {},
|
||||||
@ -79,11 +85,6 @@ describe('Upload | extensions | entity-manager', () => {
|
|||||||
media: media[0],
|
media: media[0],
|
||||||
};
|
};
|
||||||
|
|
||||||
const spySignFileUrls = jest.fn();
|
|
||||||
getService.mockImplementation(() => ({
|
|
||||||
signFileUrls: spySignFileUrls,
|
|
||||||
}));
|
|
||||||
|
|
||||||
await signEntityMedia(entity, modelUID);
|
await signEntityMedia(entity, modelUID);
|
||||||
expect(getService).toBeCalledWith('file');
|
expect(getService).toBeCalledWith('file');
|
||||||
expect(spySignFileUrls).toBeCalledWith(entity.media);
|
expect(spySignFileUrls).toBeCalledWith(entity.media);
|
||||||
@ -94,11 +95,6 @@ describe('Upload | extensions | entity-manager', () => {
|
|||||||
media_repeatable: media,
|
media_repeatable: media,
|
||||||
};
|
};
|
||||||
|
|
||||||
const spySignFileUrls = jest.fn();
|
|
||||||
getService.mockImplementation(() => ({
|
|
||||||
signFileUrls: spySignFileUrls,
|
|
||||||
}));
|
|
||||||
|
|
||||||
await signEntityMedia(entity, modelUID);
|
await signEntityMedia(entity, modelUID);
|
||||||
expect(getService).toBeCalledWith('file');
|
expect(getService).toBeCalledWith('file');
|
||||||
expect(spySignFileUrls).toBeCalledTimes(2);
|
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);
|
await signEntityMedia(entity, modelUID);
|
||||||
expect(getService).toBeCalledWith('file');
|
expect(getService).toBeCalledWith('file');
|
||||||
expect(spySignFileUrls).toBeCalledTimes(3);
|
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);
|
await signEntityMedia(entity, modelUID);
|
||||||
expect(getService).toBeCalledWith('file');
|
expect(getService).toBeCalledWith('file');
|
||||||
expect(spySignFileUrls).toBeCalledTimes(6);
|
expect(spySignFileUrls).toBeCalledTimes(6);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user