diff --git a/src/test-helpers/deleteThoughtAtFirstMatch.ts b/src/test-helpers/deleteThoughtAtFirstMatch.ts index 92962f3263..f2afa010b7 100644 --- a/src/test-helpers/deleteThoughtAtFirstMatch.ts +++ b/src/test-helpers/deleteThoughtAtFirstMatch.ts @@ -12,13 +12,15 @@ import rootedParentOf from '../selectors/rootedParentOf' /** * Get thought and context for the given unranked path. */ -const getThoughtAndParentPath = (state: State, at: string[]): [Thought | undefined, Path] => { +const getThoughtAndParentPath = (state: State, at: string[]): [Thought, Path] => { const path = contextToPath(state, at) if (!path) throw new Error(`Ranked thoughts not found for context: ${at}`) const thought = pathToThought(state, path) + if (!thought) throw new Error(`Thought not found for path: ${path}`) + const pathParent = rootedParentOf(state, path) return [thought, pathParent] @@ -28,10 +30,7 @@ const getThoughtAndParentPath = (state: State, at: string[]): [Thought | undefin */ const deleteThoughtAtFirstMatch = _.curryRight((state: State, at: string[]) => { const [thought, pathParent] = getThoughtAndParentPath(state, at) - if (!thought) { - console.warn(`Aborting deleteThoughtAtFirstMatch for ${at} because thought not found`) - return state - } + return deleteThought(state, { pathParent, thoughtId: thought.id, @@ -45,10 +44,7 @@ export const deleteThoughtAtFirstMatchActionCreator = (at: Context): Thunk => (dispatch, getState) => { const [thought, pathParent] = getThoughtAndParentPath(getState(), at) - if (!thought) { - console.warn(`Aborting deleteThoughtAtFirstMatch for ${at} because thought not found`) - return - } + dispatch( deleteThoughtActionCreator({ pathParent,