mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 02:35:23 -04:00

Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
30 lines
846 B
TypeScript
30 lines
846 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
import * as useApplicationStateModule from '../hooks/common/use-application-state'
|
|
import type { ApplicationState } from '../redux/application-state'
|
|
|
|
jest.mock('../hooks/common/use-application-state')
|
|
export const mockNoteOwnership = (
|
|
ownUsername: string,
|
|
noteOwner: string,
|
|
additionalState?: Partial<ApplicationState>
|
|
) => {
|
|
jest.spyOn(useApplicationStateModule, 'useApplicationState').mockImplementation((fn) => {
|
|
return fn({
|
|
...additionalState,
|
|
noteDetails: {
|
|
...additionalState?.noteDetails,
|
|
permissions: {
|
|
owner: noteOwner
|
|
}
|
|
},
|
|
user: {
|
|
...additionalState?.user,
|
|
username: ownUsername
|
|
}
|
|
} as ApplicationState)
|
|
})
|
|
}
|