-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathindex.ssr.test.ts
28 lines (24 loc) · 1019 Bytes
/
index.ssr.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import {renderHook} from '@testing-library/react-hooks/server';
import {describe, expect, it} from 'vitest';
import {useMediaQuery} from '../index.js';
describe('useMediaQuery', () => {
it('should be defined', () => {
expect(useMediaQuery).toBeDefined();
});
it('should render', () => {
const {result} = renderHook(() =>
useMediaQuery('max-width : 768px', {initializeWithValue: false}));
expect(result.error).toBeUndefined();
});
it('should return undefined on first render, if initializeWithValue is set to false', () => {
const {result} = renderHook(() =>
useMediaQuery('max-width : 768px', {initializeWithValue: false}));
expect(result.current).toBeUndefined();
});
it('should return undefined on first render, when not enabled and initializeWithValue is set to true', () => {
const {result} = renderHook(() =>
useMediaQuery('max-width : 768px', {initializeWithValue: true, enabled: false}));
expect(result.error).toBeUndefined();
expect(result.current).toBeUndefined();
});
});