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

react-moment-proptypes

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-moment-proptypes - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

test-site/bundle.js

2

package.json
{
"name": "react-moment-proptypes",
"version": "1.3.0",
"version": "1.4.0",
"description": "React proptype for moment module",

@@ -5,0 +5,0 @@ "keywords": [

@@ -16,2 +16,8 @@ var moment = require('moment');

function createInvalidRequiredErrorMessage(propName, componentName, value) {
return new Error(
'The prop `' + propName + '` is marked as required in `' + componentName + '`, but its value is `' + value + '`.'
);
}
function createMomentChecker(type, typeValidator, validator, momentType) {

@@ -28,19 +34,19 @@

) {
var propValue = props[ propName ];
var propType = typeof propValue;
var isPropValueUndefined = typeof propValue === 'undefined';
var isPropValueNull = propValue === null;
if (isRequired) {
var locationName = ReactPropTypeLocationNames[ location ];
componentName = componentName || ANONYMOUS;
propFullName = propFullName || propName;
if (!props.hasOwnProperty(propName)) {
return new Error(
'Required ' + locationName + ' `' + propFullName +
'` was not specified in `' +
componentName + '`.'
);
if (isPropValueUndefined) {
return createInvalidRequiredErrorMessage(propFullName, componentName, 'undefined');
} else if (isPropValueNull) {
return createInvalidRequiredErrorMessage(propFullName, componentName, 'null');
}
}
var propValue = props[ propName ];
var propType = typeof propValue;
if (typeof propValue === 'undefined' || propValue === null) {
if (isPropValueUndefined || isPropValueNull) {
return null;

@@ -47,0 +53,0 @@ }

@@ -77,3 +77,3 @@ import React from 'react';

expect(warnings.length).to.equal(1);
expect(warnings[0]).to.contain('Required prop');
expect(warnings[0]).to.contain('required');
done();

@@ -85,2 +85,61 @@

describe('null required object', () => {
before(() => {
TestClass = React.createClass({
propTypes : {
testRequiredObject : MomentPropTypes.momentObj.isRequired,
},
render() {
return null;
},
});
});
it('should have a warning for the null moment obj', (done) => {
const testElement = <TestClass testRequiredObject={null}/>;
TestUtils.renderIntoDocument(testElement);
expect(warnings).to.be.an('array');
expect(warnings.length).to.equal(1);
expect(warnings[0]).to.contain('required');
expect(warnings[0]).to.contain('null');
done();
});
});
// describe('undefined required object', () => {
//
// before(() => {
//
// TestClass = React.createClass({
// propTypes : {
// testRequiredObject : MomentPropTypes.momentObj.isRequired,
// },
// render() {
// return null;
// },
// });
//
// });
//
// it('should have a warning for the undefined moment obj', (done) => {
// const testElement = <TestClass testRequiredObject={undefined}/>;
// TestUtils.renderIntoDocument(testElement);
//
// expect(warnings).to.be.an('array');
// expect(warnings.length).to.equal(1);
// expect(warnings[0]).to.contain('required');
// expect(warnings[0]).to.contain('undefined');
// done();
//
// });
//
// });
describe('Missing optional object', () => {

@@ -168,3 +227,3 @@

expect(warnings.length).to.equal(1);
expect(warnings[0]).to.contain('Required prop');
expect(warnings[0]).to.contain('required');
done();

@@ -176,2 +235,62 @@

describe('null required string', () => {
before(() => {
TestClass = React.createClass({
propTypes : {
testRequiredString : MomentPropTypes.momentString.isRequired,
},
render() {
return null;
},
});
});
it('should have a warning for the null moment string', (done) => {
const testElement = <TestClass testRequiredString={null}/>;
TestUtils.renderIntoDocument(testElement);
expect(warnings).to.be.an('array');
expect(warnings.length).to.equal(1);
expect(warnings[0]).to.contain('required');
expect(warnings[0]).to.contain('null');
done();
});
});
// describe('undefined required string', () => {
//
// before(() => {
//
// TestClass = React.createClass({
// propTypes : {
// testRequiredString : MomentPropTypes.momentString.isRequired,
// },
// render() {
// return null;
// },
// });
//
// });
//
// it('should have a warning for the undefined moment string', (done) => {
//
// const testElement = <TestClass testRequiredString={undefined}/>;
// TestUtils.renderIntoDocument(testElement);
//
// expect(warnings).to.be.an('array');
// expect(warnings.length).to.equal(1);
// expect(warnings[0]).to.contain('required');
// expect(warnings[0]).to.contain('undefined');
// done();
//
// });
//
// });
describe('Missing optional string', () => {

@@ -178,0 +297,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