fix(frontend): verify that callback could be run in create-non-existing-note-hint.test.tsx

Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
Philip Molares 2023-01-15 22:16:41 +01:00 committed by Erik Michelson
parent 5f238e9651
commit eacd81cb9c

View file

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file) * SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
* *
* SPDX-License-Identifier: AGPL-3.0-only * SPDX-License-Identifier: AGPL-3.0-only
*/ */
@ -68,6 +68,7 @@ describe('create non existing note hint', () => {
const onNoteCreatedCallback = jest.fn() const onNoteCreatedCallback = jest.fn()
const view = render(<CreateNonExistingNoteHint onNoteCreated={onNoteCreatedCallback}></CreateNonExistingNoteHint>) const view = render(<CreateNonExistingNoteHint onNoteCreated={onNoteCreatedCallback}></CreateNonExistingNoteHint>)
await screen.findByTestId('createNoteMessage') await screen.findByTestId('createNoteMessage')
await waitForOtherPromisesToFinish()
expect(onNoteCreatedCallback).not.toBeCalled() expect(onNoteCreatedCallback).not.toBeCalled()
expect(view.container).toMatchSnapshot() expect(view.container).toMatchSnapshot()
}) })
@ -83,6 +84,7 @@ describe('create non existing note hint', () => {
await waitFor(async () => { await waitFor(async () => {
expect(await screen.findByTestId('loadingMessage')).toBeInTheDocument() expect(await screen.findByTestId('loadingMessage')).toBeInTheDocument()
}) })
await waitForOtherPromisesToFinish()
expect(onNoteCreatedCallback).not.toBeCalled() expect(onNoteCreatedCallback).not.toBeCalled()
expect(view.container).toMatchSnapshot() expect(view.container).toMatchSnapshot()
}) })
@ -98,6 +100,7 @@ describe('create non existing note hint', () => {
await waitFor(async () => { await waitFor(async () => {
expect(await screen.findByTestId('noteCreated')).toBeInTheDocument() expect(await screen.findByTestId('noteCreated')).toBeInTheDocument()
}) })
await waitForOtherPromisesToFinish()
expect(onNoteCreatedCallback).toBeCalled() expect(onNoteCreatedCallback).toBeCalled()
expect(view.container).toMatchSnapshot() expect(view.container).toMatchSnapshot()
}) })
@ -113,6 +116,7 @@ describe('create non existing note hint', () => {
await waitFor(async () => { await waitFor(async () => {
expect(await screen.findByTestId('failedMessage')).toBeInTheDocument() expect(await screen.findByTestId('failedMessage')).toBeInTheDocument()
}) })
await waitForOtherPromisesToFinish()
expect(onNoteCreatedCallback).not.toBeCalled() expect(onNoteCreatedCallback).not.toBeCalled()
expect(view.container).toMatchSnapshot() expect(view.container).toMatchSnapshot()
}) })