react-native-timer-picker
Version: 
A simple, flexible, performant duration picker for React Native apps 🔥 Great for timers, alarms and duration inputs ⏰🕰️⏳ Includes iOS-style haptic and audio feedback 🍏
48 lines • 1.97 kB
JavaScript
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
import React from "react";
import { render } from "@testing-library/react-native";
import { FlatList } from "react-native";
import TimerPicker from "../components/TimerPicker";
describe("TimerPicker", () => {
  it("renders without crashing", () => {
    const {
      getByTestId
    } = render(/*#__PURE__*/React.createElement(TimerPicker, null));
    const component = getByTestId("timer-picker");
    expect(component).toBeDefined();
  });
  it("renders without crashing with negative padWithNItems", () => {
    const {
      getByTestId
    } = render(/*#__PURE__*/React.createElement(TimerPicker, {
      padWithNItems: -1
    }));
    const component = getByTestId("timer-picker");
    expect(component).toBeDefined();
  });
  it("hides minutes and seconds when respective hide props are provided", () => {
    const {
      queryByTestId
    } = render(/*#__PURE__*/React.createElement(TimerPicker, {
      hideMinutes: true,
      hideSeconds: true
    }));
    const minutePicker = queryByTestId("duration-scroll-minute");
    const secondPicker = queryByTestId("duration-scroll-second");
    expect(minutePicker).toBeNull();
    expect(secondPicker).toBeNull();
  });
  it("uses the custom FlatList component when provided", () => {
    const CustomFlatList = props => /*#__PURE__*/React.createElement(FlatList, _extends({}, props, {
      testID: "custom-flat-list"
    }));
    const {
      queryAllByTestId
    } = render(/*#__PURE__*/React.createElement(TimerPicker, {
      FlatList: CustomFlatList
    }));
    const customFlatList = queryAllByTestId("custom-flat-list");
    expect(customFlatList).toHaveLength(3);
  });
});
//# sourceMappingURL=TimerPicker.test.js.map