mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-09 13:51:57 -04:00
fix: improve deep partial type used in tests
The deep partial type from redux had the problem that it could only be applied to records. This caused problems with primitive types and arrays. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
b5b61aec6a
commit
8a745f3f32
4 changed files with 19 additions and 8 deletions
|
@ -5,7 +5,6 @@
|
|||
*/
|
||||
import * as useApplicationStateModule from '../hooks/common/use-application-state'
|
||||
import type { ApplicationState } from '../redux/application-state'
|
||||
import type { DeepPartial } from 'redux'
|
||||
import { initialState as initialStateDarkMode } from '../redux/dark-mode/reducers'
|
||||
import { initialState as initialStateEditorConfig } from '../redux/editor/reducers'
|
||||
import { initialState as initialStateNoteDetails } from '../redux/note-details/initial-state'
|
||||
|
@ -13,7 +12,7 @@ import { initialState as initialStateRealtimeStatus } from '../redux/realtime/re
|
|||
import { initialState as initialStateRendererStatus } from '../redux/renderer-status/reducers'
|
||||
import type { NoteDetails } from '../redux/note-details/types/note-details'
|
||||
import type { RealtimeStatus } from '../redux/realtime/types'
|
||||
import type { HistoryEntryWithOrigin } from '../api/history/types'
|
||||
import type { DeepPartial } from '@hedgedoc/commons'
|
||||
|
||||
jest.mock('../redux/editor/methods', () => ({
|
||||
loadFromLocalStorage: jest.fn().mockReturnValue(undefined)
|
||||
|
@ -37,7 +36,7 @@ export const mockAppState = (state?: DeepPartial<ApplicationState>) => {
|
|||
...initialStateEditorConfig,
|
||||
...state?.editorConfig
|
||||
},
|
||||
history: (state?.history ?? []) as HistoryEntryWithOrigin[],
|
||||
history: state?.history ?? [],
|
||||
noteDetails: {
|
||||
...initialStateNoteDetails,
|
||||
...state?.noteDetails
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { ApplicationState } from '../redux/application-state'
|
||||
import type { DeepPartial } from 'redux'
|
||||
import { mockAppState } from './mock-app-state'
|
||||
import type { LoginUserInfo } from '../api/me/types'
|
||||
import type { NotePermissions } from '@hedgedoc/commons'
|
||||
import type { DeepPartial, NotePermissions } from '@hedgedoc/commons'
|
||||
|
||||
/**
|
||||
* Mocks the {@link NotePermissions} field of a note in the {@link ApplicationState }for a test.
|
||||
|
@ -38,6 +36,6 @@ export const mockNotePermissions = (
|
|||
user: {
|
||||
...additionalState?.user,
|
||||
username: ownUsername
|
||||
} as LoginUserInfo
|
||||
})
|
||||
}
|
||||
} as DeepPartial<ApplicationState>)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue