aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/hooks/use-scroll-lock/use-scroll-lock.test.tsx
blob: f8234e15602a27760a2a7508be04879122f39819 (plain)
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
import { describe, expect, it } from '@jest/globals';
import { render } from '@testing-library/react';
import { useScrollLock } from './use-scroll-lock';

const body = 'eligendi dolor eos';

const UseScrollLockDemo = ({ isLocked }: { isLocked: boolean }) => {
  useScrollLock(isLocked);

  return <div>{body}</div>;
};

describe('use-scroll-lock', () => {
  it('can disable scroll on body element', () => {
    const { baseElement } = render(<UseScrollLockDemo isLocked />);

    expect(baseElement).toHaveStyle({ overflow: 'hidden' });
  });

  it('can enable scroll on body element', () => {
    const { baseElement } = render(<UseScrollLockDemo isLocked={false} />);

    expect(baseElement).not.toHaveStyle({ overflow: 'hidden' });
  });
});