ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
1005 B

  1. import { render, screen } from '@testing-library/react'
  2. import { afterEach, describe, expect, it } from 'vitest'
  3. import RouteBlockerOverlay, { useOverlayStore } from '@/components/RouteBlockerOverlay'
  4. describe ('RouteBlockerOverlay', () => {
  5. afterEach (() => {
  6. useOverlayStore.setState ({ active: false })
  7. document.body.style.overflow = ''
  8. document.body.removeAttribute ('aria-busy')
  9. })
  10. it ('renders nothing while inactive', () => {
  11. useOverlayStore.setState ({ active: false })
  12. const { container } = render (<RouteBlockerOverlay/>)
  13. expect (container).toBeEmptyDOMElement ()
  14. })
  15. it ('renders a blocking progressbar and marks the body busy while active', () => {
  16. useOverlayStore.setState ({ active: true })
  17. render (<RouteBlockerOverlay/>)
  18. expect (screen.getByRole ('progressbar', { name: 'Loading' })).toBeInTheDocument ()
  19. expect (document.body).toHaveAttribute ('aria-busy', 'true')
  20. expect (document.body.style.overflow).toBe ('hidden')
  21. })
  22. })