Skip to content

Commit

Permalink
test: add unit test for useMediaQuery (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamenai authored Jun 10, 2024
1 parent 2eb881c commit 1b80083
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/hooks/__tests__/use-media-query.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useMediaQuery } from '../use-media-query'
import { renderHook } from '@testing-library/react'

describe('useMediaQuery', () => {
it('should return 320 for xs media query', () => {
const { result } = renderHook(() => useMediaQuery('xs'))
expect(result.current.mediaWidth).toEqual(320)
})

it('should return 480 for sm media query', () => {
const { result } = renderHook(() => useMediaQuery('sm'))
expect(result.current.mediaWidth).toEqual(480)
})

it('should return 1024 for lg media query', () => {
const { result } = renderHook(() => useMediaQuery('lg'))
expect(result.current.mediaWidth).toEqual(1024)
})

it('should return 1200 for xl media query', () => {
const { result } = renderHook(() => useMediaQuery('xl'))
expect(result.current.mediaWidth).toEqual(1200)
})
})

0 comments on commit 1b80083

Please sign in to comment.