react-moment-proptypes
Advanced tools
Comparing version 1.1.2 to 1.2.0
{ | ||
"name": "react-moment-proptypes", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "React proptype for moment module", | ||
@@ -11,3 +11,3 @@ "keywords": [ | ||
], | ||
"main": "index.js", | ||
"main": "./src/index.js", | ||
"repository": { | ||
@@ -21,2 +21,5 @@ "type": "git", | ||
"test": "./node_modules/.bin/mocha --recursive --compilers js:babel/register --require ./test/setup.js", | ||
"test-all": "npm run test-1.6 && npm run test-1.7 && rm -Rf ./node_modules/moment/ && npm i && npm test", | ||
"test-1.6": "rm -Rf ./node_modules/moment/ && npm i moment@1.6.0 && npm test", | ||
"test-1.7": "rm -Rf ./node_modules/moment/ && npm i moment@1.7.0 && npm test", | ||
"lint": "./node_modules/.bin/eslint --ext .js .", | ||
@@ -32,3 +35,3 @@ "lint-quiet": "./node_modules/.bin/eslint --ext .js --quiet .", | ||
"dependencies": { | ||
"moment": ">=1.5.0" | ||
"moment": ">=1.6.0" | ||
}, | ||
@@ -35,0 +38,0 @@ "devDependencies": { |
@@ -18,2 +18,3 @@ # react-moment-proptypes | ||
stringThing : momentPropTypes.momentString, | ||
durationThing: momentPropTypes.momentDurationObj, | ||
}, | ||
@@ -28,3 +29,4 @@ | ||
<TestClass dateThing={moment()} | ||
stringThing={'12-12-2014'} /> | ||
stringThing={'12-12-2014'} | ||
durationThing={moment.duration(3, 'hours')}/> | ||
@@ -39,1 +41,7 @@ ``` | ||
- `npm run coverage` for current test coverage | ||
## Moment Versions | ||
- `npm run test-all` to test against tested moment version (1.6.0, 1.7.0, current) | ||
If there is a desire for varying moment legacy support I'm willing to add it, but will stick to YAGNI until then. |
@@ -8,6 +8,13 @@ import React from 'react'; | ||
import MomentPropTypes from '../index'; | ||
import MomentPropTypes from '../src/index'; | ||
function constructWarningsMessage(warnings) { | ||
return 'warnings: ' + JSON.stringify(warnings); | ||
var message = ''; | ||
try { | ||
message = 'warnings: ' + JSON.stringify(warnings); | ||
} catch (err) { | ||
console.log('Error creating test message', err.stack); | ||
} | ||
return message; | ||
} | ||
@@ -93,3 +100,3 @@ | ||
it('should have no warnings for Missing optinal moment obj', (done) => { | ||
it('should have no warnings for Missing optional moment obj', (done) => { | ||
@@ -114,2 +121,3 @@ const testElement = <TestClass/>; | ||
testWrongObject : MomentPropTypes.momentObj, | ||
testWrongDuration : MomentPropTypes.momentDurationObj, | ||
}, | ||
@@ -123,10 +131,12 @@ render() { | ||
it('should have no warnings for optinal moment obj being wrong type', (done) => { | ||
it('should have warnings for optional moment and duration objects being wrong type', (done) => { | ||
const testElement = <TestClass testWrongObject={1} />; | ||
const testElement = <TestClass testWrongObject={1} testWrongDuration={moment()}/>; | ||
TestUtils.renderIntoDocument(testElement); | ||
expect(warnings).to.be.an('array'); | ||
expect(warnings.length).to.equal(1); | ||
expect(warnings[0]).to.contain('Invalid input type'); | ||
expect(warnings.length).to.equal(2); | ||
expect(warnings[0]).to.include('Invalid input type'); | ||
expect(warnings[1]).to.include('Invalid prop'); | ||
expect(warnings[1]).to.include('Duration'); | ||
done(); | ||
@@ -235,8 +245,8 @@ | ||
const testElement = <TestClass testWrongString={'test'} />; | ||
const testElement = <TestClass testWrongString={'not a date'} />; | ||
TestUtils.renderIntoDocument(testElement); | ||
expect(warnings).to.be.an('array'); | ||
expect(warnings.length).to.equal(1); | ||
expect(warnings[0]).to.contain('Invalid prop'); | ||
expect(warnings).to.be.an('array', constructWarningsMessage(warnings)); | ||
expect(warnings.length).to.equal(1, constructWarningsMessage(warnings)); | ||
expect(warnings[0]).to.contain('Invalid prop', constructWarningsMessage(warnings)); | ||
done(); | ||
@@ -256,2 +266,3 @@ | ||
testValidObject : MomentPropTypes.momentObj, | ||
testValidDuration : MomentPropTypes.momentDurationObj, | ||
}, | ||
@@ -266,8 +277,13 @@ render() { | ||
it('should have no warnings for the optional moment string', (done) => { | ||
const testProps = { | ||
testValidString : '12-12-2015', | ||
testValidObject : moment(), | ||
testValidDuration : moment.duration(0), | ||
}; | ||
const testElement = <TestClass testValidString={'12-12-2015'} testValidObject={moment()} />; | ||
const testElement = <TestClass {...testProps} />; | ||
TestUtils.renderIntoDocument(testElement); | ||
expect(warnings).to.be.an('array'); | ||
expect(warnings.length).to.equal(0); | ||
expect(warnings).to.be.an('array', constructWarningsMessage(warnings)); | ||
expect(warnings.length).to.equal(0, constructWarningsMessage(warnings)); | ||
done(); | ||
@@ -287,2 +303,3 @@ | ||
testValidObject : MomentPropTypes.momentObj.isRequired, | ||
testValidDuration : MomentPropTypes.momentDurationObj.isRequired, | ||
}, | ||
@@ -297,4 +314,8 @@ render() { | ||
it('should have no warnings for the optional moment string', (done) => { | ||
const testElement = <TestClass testValidString={'12-12-2015'} testValidObject={moment()} />; | ||
const testProps = { | ||
testValidString : '12-12-2015', | ||
testValidObject : moment(), | ||
testValidDuration : moment.duration(0), | ||
}; | ||
const testElement = <TestClass {...testProps} />; | ||
TestUtils.renderIntoDocument(testElement); | ||
@@ -301,0 +322,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19476
11
320
45
Updatedmoment@>=1.6.0