Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-raw-bottom-sheet

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-raw-bottom-sheet - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

80

__tests__/RBSheet.test.js
import React from "react";
import { View, Text } from "react-native";
import { View, Text, Modal, TouchableOpacity } from "react-native";
import Enzyme, { shallow } from "enzyme";

@@ -56,9 +56,29 @@ import Adapter from "enzyme-adapter-react-16";

wrapper.instance().createPanResponder({ closeOnSwipeDown: true, height: 300 });
expect(createPanResponder).toHaveBeenCalled();
expect(createPanResponder).toHaveBeenCalledTimes(1);
});
it("should component open", () => {
let wrapper;
let setModalVisible;
const onClose = jest.fn();
beforeEach(() => {
wrapper = shallow(<RBSheet onClose={onClose} />);
setModalVisible = jest.spyOn(RBSheet.prototype, "setModalVisible");
jest.useFakeTimers(); // https://github.com/facebook/jest/issues/4359
const wrapper = shallow(<RBSheet />);
const setModalVisible = jest.spyOn(RBSheet.prototype, "setModalVisible");
jest.mock("Animated", () => {
const ActualAnimated = require.requireActual("Animated");
return {
...ActualAnimated,
timing: (value, config) => {
return {
start: callback => {
value.setValue(config.toValue);
if (typeof callback === "function") callback();
}
};
}
};
});
});
it("should method open called", () => {
wrapper.instance().open();

@@ -69,6 +89,3 @@ expect(setModalVisible).toHaveBeenCalled();

it("should component close", () => {
jest.useFakeTimers(); // https://github.com/facebook/jest/issues/4359
const wrapper = shallow(<RBSheet />);
const setModalVisible = jest.spyOn(RBSheet.prototype, "setModalVisible");
it("should method close called", () => {
wrapper.instance().close();

@@ -78,3 +95,48 @@ expect(setModalVisible).toHaveBeenCalled();

});
it("should onClose callback function called", () => {
wrapper.instance().close();
expect(onClose).toHaveBeenCalled();
});
});
describe("Button", () => {
it("should render <TouchableOpacity>", () => {
const wrapper = shallow(<RBSheet />);
expect(wrapper.find(TouchableOpacity).length).toEqual(1);
});
it("should closeOnPressMask when given prop true", () => {
const wrapper = shallow(<RBSheet closeOnPressMask />);
wrapper.instance().close = jest.fn();
wrapper.find(TouchableOpacity).simulate("Press");
expect(wrapper.instance().close).toHaveBeenCalled();
});
it("should not closeOnPressMask when given prop false", () => {
const wrapper = shallow(<RBSheet closeOnPressMask={false} />);
wrapper.instance().close = jest.fn();
wrapper.find(TouchableOpacity).simulate("Press");
expect(wrapper.instance().close).not.toHaveBeenCalled();
});
});
describe("Modal", () => {
it("should render <Modal>", () => {
const wrapper = shallow(<RBSheet />);
expect(wrapper.find(Modal).length).toEqual(1);
});
it("should onRequestClose called", () => {
const mockFn = jest.fn();
RBSheet.prototype.setModalVisible = mockFn;
const wrapper = shallow(<RBSheet />);
wrapper
.find(Modal)
.props()
.onRequestClose();
expect(mockFn).toHaveBeenCalled();
});
});
});

2

package.json
{
"name": "react-native-raw-bottom-sheet",
"version": "1.1.3",
"version": "1.1.4",
"description": "Add Your Own Component To Bottom Sheet Whatever You Want (Android & iOS)",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,2 +15,3 @@ # react-native-raw-bottom-sheet

- Support Both Android And iOS
- Top Search Ranking (react native bottom sheet) at [npms.io](https://npms.io/search?q=react%20native%20bottom%20sheet)

@@ -79,2 +80,3 @@ | Showcase iOS | Showcase Android |

| ---------------- | -------- | ---------------------------------------------- | -------- |
| animationType | string | Background animation ("none", "fade", "slide") | "none" |
| height | number | Height of Bottom Sheet | 260 |

@@ -81,0 +83,0 @@ | minClosingHeight | number | Minimum height of Bottom Sheet before close | 0 |

@@ -80,3 +80,3 @@ import React, { Component } from "react";

render() {
const { closeOnPressMask, children, customStyles } = this.props;
const { animationType, closeOnPressMask, children, customStyles } = this.props;
const { animatedHeight, pan, modalVisible } = this.state;

@@ -90,3 +90,3 @@ const panStyle = {

transparent
animationType="none"
animationType={animationType}
visible={modalVisible}

@@ -117,2 +117,3 @@ supportedOrientations={SUPPORTED_ORIENTATIONS}

RBSheet.propTypes = {
animationType: PropTypes.oneOf(["none", "slide", "fade"]),
height: PropTypes.number,

@@ -129,2 +130,3 @@ minClosingHeight: PropTypes.number,

RBSheet.defaultProps = {
animationType: "none",
height: 260,

@@ -131,0 +133,0 @@ minClosingHeight: 0,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc