import { renderHook, act } from '@testing-library/react';
import { useFullScreenDrawer } from './useFullScreenDrawer';
describe('useFullScreenDrawer', function () {
  it('should use isShown passed from outside as initial value', function () {
    const {
      result
    } = renderHook(() => useFullScreenDrawer({
      isShow: true
    }));
    expect(result.current.show).toBe(true);
  });
  it('should invoke onDismissCallback passed to it', function () {
    const outerDismiss = jest.fn();
    const {
      result
    } = renderHook(() => useFullScreenDrawer({
      onDismissCallback: outerDismiss
    }));
    act(() => result.current.onDismiss());
    expect(outerDismiss).toHaveBeenCalled();
  });
  it('should set showCloseWarning to true when onDismiss is called if shouldShowCloseWarning is passed as true', function () {
    const outerDismiss = jest.fn();
    const {
      result
    } = renderHook(() => useFullScreenDrawer({
      onDismissCallback: outerDismiss,
      shouldShowCloseWarning: true
    }));
    act(() => result.current.onDismiss());
    expect(outerDismiss).not.toHaveBeenCalled();
    expect(result.current.showCloseWarning).toBe(true);
  });
  it('should set showCloseWarning to false when onDismiss is called if shouldShowCloseWarning is passed as false', function () {
    const outerDismiss = jest.fn();
    const {
      result
    } = renderHook(() => useFullScreenDrawer({
      onDismissCallback: outerDismiss,
      shouldShowCloseWarning: false
    }));
    act(() => result.current.onDismiss());
    expect(outerDismiss).toHaveBeenCalled();
    expect(result.current.showCloseWarning).toBe(false);
  });
  it('should close drawer after onDismiss is called twice', function () {
    const outerDismiss = jest.fn();
    const {
      result
    } = renderHook(() => useFullScreenDrawer({
      isShow: true,
      onDismissCallback: outerDismiss,
      shouldShowCloseWarning: true
    }));
    act(() => result.current.onDismiss());
    expect(outerDismiss).not.toHaveBeenCalled();
    act(() => result.current.onDismiss());
    expect(outerDismiss).toHaveBeenCalled();
    expect(result.current.show).toBe(false);
  });
});