Skip to content

Commit

Permalink
cleanup: replace initialState with stateFactory.build()
Browse files Browse the repository at this point in the history
  • Loading branch information
firestack committed Oct 1, 2024
1 parent ab9dcb5 commit 35dcb01
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions assets/tests/components/notificationBellIcon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from "../../src/contexts/notificationsContext"
import { StateDispatchProvider } from "../../src/contexts/stateDispatchContext"
import { Notification } from "../../src/realtime"
import { initialState } from "../../src/state"
import { OpenView } from "../../src/state/pagePanelState"
import stateFactory from "../factories/applicationState"
import { viewFactory } from "../factories/pagePanelStateFactory"
Expand Down Expand Up @@ -74,10 +73,9 @@ const readNotificationState: NotificationsState = {

describe("NotificationBellIcon", () => {
test("renders when the drawer is closed and there are new notifications", () => {
const state = { ...initialState, openView: OpenView.None }
const tree = renderer
.create(
<StateDispatchProvider state={state} dispatch={jest.fn()}>
<StateDispatchProvider state={stateFactory.build()} dispatch={jest.fn()}>
<NotificationsContext.Provider value={unreadNotificationState}>
<NotificationBellIcon />
</NotificationsContext.Provider>
Expand Down Expand Up @@ -108,10 +106,9 @@ describe("NotificationBellIcon", () => {
})

test("renders when the drawer is closed and there are not new notifications", () => {
const state = { ...initialState, openView: OpenView.None }
const tree = renderer
.create(
<StateDispatchProvider state={state} dispatch={jest.fn()}>
<StateDispatchProvider state={stateFactory.build()} dispatch={jest.fn()}>
<NotificationsContext.Provider value={readNotificationState}>
<NotificationBellIcon />
</NotificationsContext.Provider>
Expand Down Expand Up @@ -142,9 +139,8 @@ describe("NotificationBellIcon", () => {
test("renders when there are new detour notifications and user is part of DetoursList group", () => {
jest.mocked(getTestGroups).mockReturnValue([TestGroups.DetoursList])

const state = { ...initialState, openView: OpenView.None }
const { baseElement } = render(
<StateDispatchProvider state={state} dispatch={jest.fn()}>
<StateDispatchProvider state={stateFactory.build()} dispatch={jest.fn()}>
<NotificationsContext.Provider value={unreadDetourNotificationState}>
<NotificationBellIcon />
</NotificationsContext.Provider>
Expand All @@ -155,9 +151,8 @@ describe("NotificationBellIcon", () => {
})

test("renders when there are new detour notifications and user is not part of DetoursList", () => {
const state = { ...initialState, openView: OpenView.None }
const { baseElement } = render(
<StateDispatchProvider state={state} dispatch={jest.fn()}>
<StateDispatchProvider state={stateFactory.build()} dispatch={jest.fn()}>
<NotificationsContext.Provider value={unreadDetourNotificationState}>
<NotificationBellIcon />
</NotificationsContext.Provider>
Expand Down

0 comments on commit 35dcb01

Please sign in to comment.