"use strict";

var _reactNative = require("@testing-library/react-native");
var _react = _interopRequireDefault(require("react"));
var _NumberPad = require("../NumberPad");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const mockOnDelete = jest.fn();
const mockOnNumberPress = jest.fn();
const mockOnBiometricPress = jest.fn();
describe(_NumberPad.NumberPad, () => {
  afterEach(() => {
    jest.clearAllMocks();
    jest.restoreAllMocks();
  });
  it("Should match the snapshot", () => {
    const component = renderNumberPad();
    expect(component).toMatchSnapshot();
  });
  it("Should properly call onNumberPress without side effects", () => {
    const {
      getByText
    } = renderNumberPad();
    const one = getByText("1");
    const nine = getByText("9");
    const reactCreatElement = jest.spyOn(_react.default, "createElement");

    // Press one
    _reactNative.fireEvent.press(one);
    expect(mockOnNumberPress).toHaveBeenCalledTimes(1);
    expect(mockOnNumberPress).toHaveBeenCalledWith(1);
    mockOnNumberPress.mockClear();

    // Press nine
    _reactNative.fireEvent.press(nine);
    expect(mockOnNumberPress).toHaveBeenCalledTimes(1);
    expect(mockOnNumberPress).toHaveBeenCalledWith(9);
    expect(reactCreatElement).not.toHaveBeenCalled();
    expect(mockOnDelete).not.toHaveBeenCalled();
    expect(mockOnBiometricPress).not.toHaveBeenCalled();
  });
  it("Should properly call onDeletePress without side effects", () => {
    const {
      getByLabelText
    } = renderNumberPad();
    const deleteButton = getByLabelText("delete");
    const reactCreatElement = jest.spyOn(_react.default, "createElement");
    _reactNative.fireEvent.press(deleteButton);
    expect(mockOnDelete).toHaveBeenCalledTimes(1);
    expect(reactCreatElement).not.toHaveBeenCalled();
    expect(mockOnNumberPress).not.toHaveBeenCalled();
    expect(mockOnBiometricPress).not.toHaveBeenCalled();
  });
  it("Should properly call onBiometricPress without side effects", () => {
    const {
      getByLabelText
    } = renderNumberPad();
    const biometricButton = getByLabelText("touch id trigger");
    const reactCreatElement = jest.spyOn(_react.default, "createElement");
    _reactNative.fireEvent.press(biometricButton);
    expect(mockOnBiometricPress).toHaveBeenCalledTimes(1);
    expect(reactCreatElement).not.toHaveBeenCalled();
    expect(mockOnNumberPress).not.toHaveBeenCalled();
    expect(mockOnDelete).not.toHaveBeenCalled();
  });
});
function renderNumberPad() {
  return (0, _reactNative.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_NumberPad.NumberPad, {
    onDeletePress: mockOnDelete,
    onNumberPress: mockOnNumberPress,
    deleteAccessibilityLabel: "delete",
    biometricType: "TOUCH_ID",
    biometricAccessibilityLabel: "touch id trigger",
    onBiometricPress: mockOnBiometricPress
  }));
}
//# sourceMappingURL=NumberPad.test.js.map