Skip to content

Commit

Permalink
Fix path handling in mock sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Mar 3, 2022
1 parent bcc949c commit cb07906
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions __mocks__/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit cb07906

Please sign in to comment.