Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#35] Moved createFromInputFallback override to tests #40

Merged
merged 1 commit into from
Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ var TestClass = React.createClass({

```

# Moment Configuration

## createFromInputFallback
Moment provides a `moment.createFromInputFallback` method you can define to create additional parsing rules.

With some versions of moment you may receive the following console warning:
```
Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: not a date, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at [... stack trace]
```
Example implementations can be found at the [given documentation link](http://momentjs.com/guides/#/warnings/js-date/).


# Tests

Tests were approached with `enzyme` and React's test utility renderer
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"scripts": {
"clean": "rm -Rf ./coverage",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"test": "./node_modules/.bin/mocha --recursive --compilers js:babel/register",
"test": "./node_modules/.bin/mocha --recursive --compilers js:babel/register --require ./test/suppress-fallback-warning.js",
"test-all": "npm run test-1.6 && npm run test-1.7 && npm run test-latest",
"test-1.6": "rm -Rf ./node_modules/moment/ && npm i [email protected] && npm test",
"test-1.7": "rm -Rf ./node_modules/moment/ && npm i [email protected] && npm test",
"test-latest": "rm -Rf ./node_modules/moment/ && npm i moment@latest && npm test",
"lint": "./node_modules/.bin/eslint --ext .js .",
"lint-quiet": "./node_modules/.bin/eslint --ext .js --quiet .",
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --recursive --compilers js:babel/register"
"coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter dot --recursive --compilers js:babel/register --require ./test/suppress-fallback-warning.js"
},
"author": {
"name": "Caleb Morris",
Expand Down
4 changes: 0 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ var moment = require('moment');
var momentValidationWrapper = require('./moment-validation-wrapper');
var core = require('./core');

moment.createFromInputFallback = function(config) {
config._d = new Date(config._i);
};

module.exports = {

momentObj : core.createMomentChecker(
Expand Down
5 changes: 5 additions & 0 deletions test/suppress-fallback-warning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var moment = require('moment');

moment.createFromInputFallback = function(config) {
config._d = new Date(NaN);
};