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

is-react

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-react - npm Package Compare versions

Comparing version 0.1.10 to 0.1.12

91

__tests__/index.js
const React = require('react');
const { shallow } = require('enzyme');
const isReact = require('../');

@@ -21,40 +20,70 @@

it('Identifies a Foo class component', () => {
isReact.compatible(Foo) // true
isReact.component(Foo); // true
isReact.classComponent(Foo); // true
isReact.functionComponent(Foo); // false
isReact.element(Foo); // false
it('Classifies class component', () => {
expect(isReact.compatible(Foo)).toBe(true);
expect(isReact.component(Foo)).toBe(true);
expect(isReact.classComponent(Foo)).toBe(true);
expect(isReact.functionComponent(Foo)).toBe(false);
expect(isReact.element(Foo)).toBe(false);
});
it('Identifies a <Foo/> composite element', () => {
isReact.compatible(Foo) // true
isReact.component(Foo); // true
isReact.classComponent(Foo); // true
isReact.functionComponent(Foo); // false
isReact.element(Foo); // false
it('Classifies composite element from class component', () => {
expect(isReact.compatible(Foo)).toBe(true);
expect(isReact.component(Foo)).toBe(true);
expect(isReact.classComponent(Foo)).toBe(true);
expect(isReact.functionComponent(Foo)).toBe(false);
expect(isReact.element(Foo)).toBe(false);
});
it('Identifies a Bar function component', () => {
isReact.compatible(Bar) // true
isReact.component(Bar); // true
isReact.classComponent(Bar); // false
isReact.functionComponent(Bar); // true
isReact.element(Bar); // false
it('Classifies function component', () => {
expect(isReact.compatible(Bar)).toBe(true);
expect(isReact.component(Bar)).toBe(true);
expect(isReact.classComponent(Bar)).toBe(false);
expect(isReact.functionComponent(Bar)).toBe(true);
expect(isReact.element(Bar)).toBe(false);
});
it('Identifies a <Bar/> composite element', () => {
isReact.compatible(Bar) // true
isReact.component(Bar); // true
isReact.classComponent(Bar); // false
isReact.functionComponent(Bar); // true
isReact.element(Bar); // false
it('Classifies composite element from function component', () => {
expect(isReact.compatible(Bar)).toBe(true);
expect(isReact.component(Bar)).toBe(true);
expect(isReact.classComponent(Bar)).toBe(false);
expect(isReact.functionComponent(Bar)).toBe(true);
expect(isReact.element(Bar)).toBe(false);
});
it('Identifies a DOM type element ', () => {
isReact.compatible(header) // true
isReact.component(header); // false
isReact.element(header); // true
isReact.DOMTypeElement(header) // true
isReact.compositeTypeElement(header) // false
it('Classifies DOM type element', () => {
expect(isReact.compatible(header)).toBe(true);
expect(isReact.component(header)).toBe(false);
expect(isReact.element(header)).toBe(true);
expect(isReact.DOMTypeElement(header)).toBe(true);
expect(isReact.compositeTypeElement(header)).toBe(false);
});
describe('Native JavaScript', () => {
it('Object is not valid React', () => {
expect(isReact.compatible({})).toBe(false);
});
it('Array is not valid React', () => {
expect(isReact.compatible({})).toBe(false);
});
it('Number is not valid React', () => {
expect(isReact.compatible(1)).toBe(false);
});
it('String is not valid React', () => {
expect(isReact.compatible('Hello, world')).toBe(false);
});
it('Function is not valid React', () => {
expect(isReact.compatible(() => {})).toBe(false);
});
it('null is not valid React', () => {
expect(isReact.compatible(null)).toBe(false);
});
it('undefined is not valid React', () => {
expect(isReact.compatible(undefined)).toBe(false);
});
});
{
"name": "is-react",
"version": "0.1.10",
"version": "0.1.12",
"description": "Determine if a variable or statement is a React element or component",

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

@@ -32,3 +32,3 @@ # Is React

import React from 'react';
import isReact from 'isReact';
import isReact from 'is-react';

@@ -35,0 +35,0 @@ const MyImageComponent = ({ SomeProp }) => {

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