Skip to content

Commit

Permalink
Also mock editionStore, remove error mocks
Browse files Browse the repository at this point in the history
RISDEV-0000
  • Loading branch information
leonie-koch committed Jan 17, 2025
1 parent 0be4294 commit 7404678
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTestingPinia } from "@pinia/testing"
import { userEvent } from "@testing-library/user-event"
import { render, screen } from "@testing-library/vue"
import { createPinia, setActivePinia } from "pinia"
import { setActivePinia } from "pinia"
import { createRouter, createWebHistory } from "vue-router"
import PeriodicalEditionReferenceInput from "@/components/periodical-evaluation/references/PeriodicalEditionReferenceInput.vue"
import RelatedDocumentation from "@/domain/relatedDocumentation"
Expand All @@ -18,6 +18,10 @@ vi.mock("@/stores/extraContentSidePanelStore", () => ({
useExtraContentSidePanelStore: vi.fn(),
}))

vi.mock("@/stores/useEditionStore", () => ({
useEditionStore: vi.fn(),
}))

// Mock the useScroll composable globally
const scrollIntoViewportByIdMock = vi.fn()
const openSidePanelAndScrollToSectionMock = vi.fn()
Expand Down Expand Up @@ -64,7 +68,7 @@ function renderComponent() {
describe("Legal periodical edition reference input", () => {
beforeEach(() => {
// Activate Pinia
setActivePinia(createPinia())
setActivePinia(createTestingPinia())

// Mock the searchByRelatedDocumentation method
vi.spyOn(
Expand Down Expand Up @@ -102,7 +106,6 @@ describe("Legal periodical edition reference input", () => {
})

it("search is triggered with shortcut", async () => {
vi.spyOn(console, "error").mockImplementation(() => null)
const { user } = renderComponent()

expect(screen.queryByText(/test fileNumber1/)).not.toBeInTheDocument()
Expand All @@ -114,7 +117,6 @@ describe("Legal periodical edition reference input", () => {
})

test("adding a decision scrolls to reference on validation errors", async () => {
vi.spyOn(console, "error").mockImplementation(() => null)
const { user } = renderComponent()

await user.click(screen.getByLabelText("Nach Entscheidung suchen"))
Expand Down
5 changes: 3 additions & 2 deletions frontend/test/composables/useScroll.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createPinia, setActivePinia } from "pinia"
import { createTestingPinia } from "@pinia/testing"
import { setActivePinia } from "pinia"
import { describe, it, vi, beforeEach, afterEach, expect } from "vitest"
import { useScroll } from "@/composables/useScroll"
import { useDocumentUnitStore } from "@/stores/documentUnitStore"
Expand All @@ -20,7 +21,7 @@ describe("useScroll", () => {
beforeEach(() => {
vi.useFakeTimers()
// Activate Pinia
setActivePinia(createPinia())
setActivePinia(createTestingPinia())

// Mock the stores
documentUnitStoreMock = {
Expand Down

0 comments on commit 7404678

Please sign in to comment.