diff --git a/back/models/specs/images.spec.js b/back/models/specs/images.spec.js index 2c8cb3f4d..2c51d826d 100644 --- a/back/models/specs/images.spec.js +++ b/back/models/specs/images.spec.js @@ -7,7 +7,7 @@ let obj = {}; const STORAGE_IMAGE_USER = 'storage/image/user'; const _23_F2 = '23/f2'; const FULL_23_F2 = `full/${_23_F2}`; -describe('loopback model Image', () => { +fdescribe('loopback model Image', () => { const userId = 1107; const activeCtx = { @@ -26,6 +26,23 @@ describe('loopback model Image', () => { fileName, entityId, }; + cleanResources(); + // try { + // await fs.unlink(`${STORAGE_IMAGE_USER}/full/${FULL_23_F2}/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/160x100/${FULL_23_F2}/${nameItem}`); + + // await fs.unlink(`${STORAGE_IMAGE_USER}/520x520/${FULL_23_F2}/${nameItem}`); + + // await fs.unlink(`${STORAGE_IMAGE_USER}/1600x1600/${FULL_23_F2}/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/full/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/160x100/${nameItem}`); + + // await fs.unlink(`${STORAGE_IMAGE_USER}/520x520/${nameItem}`); + + // await fs.unlink(`${STORAGE_IMAGE_USER}/1600x1600/${nameItem}`); + // } catch (e) { + // console.warn(e); + // } }); beforeEach(() => { @@ -79,14 +96,24 @@ describe('loopback model Image', () => { }); afterAll(async() => { - try { - await fs.unlink(`${STORAGE_IMAGE_USER}/full/${nameItem}`); - - await fs.unlink(`${STORAGE_IMAGE_USER}/520x520/${nameItem}`); - - await fs.unlink(`${STORAGE_IMAGE_USER}/1600x1600/${nameItem}`); - } catch (e) { - throw new Error(e); - } + // cleanResources(); }); }); + +async function cleanResources() { + try { + await fs.unlink(`${STORAGE_IMAGE_USER}/160x160/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/160x160/${_23_F2}/${nameItem}`); + + await fs.unlink(`${STORAGE_IMAGE_USER}/520x520/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/520x520/${_23_F2}/${nameItem}`); + + await fs.unlink(`${STORAGE_IMAGE_USER}/1600x1600/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/1600x1600/${_23_F2}/${nameItem}`); + + await fs.unlink(`${STORAGE_IMAGE_USER}/full/${nameItem}`); + // await fs.unlink(`${STORAGE_IMAGE_USER}/full/${_23_F2}/${nameItem}`); + } catch (e) { + console.warn(e); + } +}