"use strict";

var _react = require("@testing-library/react");
var _useFullScreenDrawer = require("./useFullScreenDrawer");
describe('useFullScreenDrawer', function () {
  it('should use isShown passed from outside as initial value', function () {
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useFullScreenDrawer.useFullScreenDrawer)({
      isShow: true
    }));
    expect(result.current.show).toBe(true);
  });
  it('should invoke onDismissCallback passed to it', function () {
    const outerDismiss = jest.fn();
    const {
      result
    } = (0, _react.renderHook)(() => (0, _useFullScreenDrawer.useFullScreenDrawer)({
      onDismissCallback: outerDismiss
    }));
    (0, _react.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
    } = (0, _react.renderHook)(() => (0, _useFullScreenDrawer.useFullScreenDrawer)({
      onDismissCallback: outerDismiss,
      shouldShowCloseWarning: true
    }));
    (0, _react.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
    } = (0, _react.renderHook)(() => (0, _useFullScreenDrawer.useFullScreenDrawer)({
      onDismissCallback: outerDismiss,
      shouldShowCloseWarning: false
    }));
    (0, _react.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
    } = (0, _react.renderHook)(() => (0, _useFullScreenDrawer.useFullScreenDrawer)({
      isShow: true,
      onDismissCallback: outerDismiss,
      shouldShowCloseWarning: true
    }));
    (0, _react.act)(() => result.current.onDismiss());
    expect(outerDismiss).not.toHaveBeenCalled();
    (0, _react.act)(() => result.current.onDismiss());
    expect(outerDismiss).toHaveBeenCalled();
    expect(result.current.show).toBe(false);
  });
});