From cb0790698f1479738399571e6cf48dba27f7b06c Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Thu, 3 Mar 2022 17:09:43 +0100 Subject: [PATCH] Fix path handling in mock sdk --- __mocks__/sdk.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/__mocks__/sdk.js b/__mocks__/sdk.js index 7bbde9fc529..d863eb8c216 100644 --- a/__mocks__/sdk.js +++ b/__mocks__/sdk.js @@ -9,27 +9,21 @@ import fixturePublicFiles from '../__fixtures__/publicFiles' import fixtureRecipients from '../__fixtures__/recipients' import { DateTime } from 'luxon' +const mockPath = (path) => { + if (path.startsWith('/files/')) { + path = '/' + path.split('/').splice(3).join('/') + } + return path +} + export default { files: { list: (path = '/') => { - if (path.startsWith('/files/')) { - path = path.split('/').splice(3).join('/') - if (path === '') { - path = '/' - } - } - - return fixtureFiles[path] + return fixtureFiles[mockPath(path)] }, getFavoriteFiles: () => fixtureFavoriteFiles, fileInfo: (path) => { - if (path.startsWith('/files/')) { - path = path.split('/').splice(3).join('/') - if (path === '') { - path = '/' - } - } - return fixtureFiles[path][0] + return fixtureFiles[mockPath(path)][0] } }, users: {