Skip to content

Commit

Permalink
test: fix private link unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Dec 11, 2023
1 parent 3698b72 commit 2fd7a88
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions packages/web-runtime/tests/unit/pages/resolvePrivateLink.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { SHARE_JAIL_ID } from '@ownclouders/web-client/src/helpers'

jest.mock('@ownclouders/web-pkg', () => ({
...jest.requireActual('@ownclouders/web-pkg'),
useRouteQuery: jest.fn(),
useRouteParam: jest.fn(),
useRouteQuery: jest.fn((str) => str),
useRouteParam: jest.fn((str) => str),
queryItemAsString: jest.fn(),
useGetResourceContext: jest.fn(),
useConfigurationManager: jest.fn()
Expand Down Expand Up @@ -130,9 +130,18 @@ function getWrapper({
openWithDefaultAppQuery = 'true',
openLinksWithDefaultApp = true
} = {}) {
jest.mocked(queryItemAsString).mockReturnValueOnce(fileId)
jest.mocked(queryItemAsString).mockReturnValueOnce(openWithDefaultAppQuery)
jest.mocked(queryItemAsString).mockReturnValueOnce(details)
jest.mocked(queryItemAsString).mockImplementation((str: string) => {
if (str === 'fileId') {
return fileId
}
if (str === 'openWithDefaultApp') {
return openWithDefaultAppQuery
}
if (str === 'details') {
return details
}
return str
})

jest.mocked(useGetResourceContext).mockReturnValue({
getResourceContext: jest.fn().mockResolvedValue({ space, resource, path })
Expand Down

0 comments on commit 2fd7a88

Please sign in to comment.