mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-28 07:33:05 +00:00
test: cover quick action context setter hook for knip
This commit is contained in:
parent
b756f5cdf4
commit
224cbf84f5
1 changed files with 30 additions and 0 deletions
30
tests/unit/campaignQuickActionContext.unit.spec.tsx
Normal file
30
tests/unit/campaignQuickActionContext.unit.spec.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { renderHook } from '@testing-library/react'
|
||||||
|
import type { ReactNode } from 'react'
|
||||||
|
import { describe, expect, it } from 'vitest'
|
||||||
|
|
||||||
|
import {
|
||||||
|
CampaignQuickActionContextProvider,
|
||||||
|
useCampaignQuickActionContext,
|
||||||
|
useSetCampaignQuickActionContext,
|
||||||
|
} from '@/components/campaign/shell/CampaignQuickActionContext'
|
||||||
|
|
||||||
|
const wrapper = ({ children }: { children: ReactNode }) => (
|
||||||
|
<CampaignQuickActionContextProvider>{children}</CampaignQuickActionContextProvider>
|
||||||
|
)
|
||||||
|
|
||||||
|
describe('CampaignQuickActionContext', () => {
|
||||||
|
it('starts empty and accepts route context from B80+ setters', () => {
|
||||||
|
const { result, rerender } = renderHook(
|
||||||
|
() => {
|
||||||
|
useSetCampaignQuickActionContext({ municipalitySlug: 'cairu' })
|
||||||
|
return useCampaignQuickActionContext().context
|
||||||
|
},
|
||||||
|
{ wrapper },
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(result.current).toEqual({ municipalitySlug: 'cairu' })
|
||||||
|
|
||||||
|
rerender()
|
||||||
|
expect(result.current).toEqual({ municipalitySlug: 'cairu' })
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue