Skip to content

Commit

Permalink
#46 Increased testability of provider.utils.js module
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrohsilveira committed Feb 5, 2018
1 parent a73ff9d commit ccd70a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-formctrl/src/provider/provider.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function ensureStringValue(value, type) {
}

export function formatDate(date) {
if(date) {
if(date && date instanceof Date) {
const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : `${date.getMonth() + 1}`
const day = date.getDate() < 10 ? `0${date.getDate()}` : `${date.getDate()}`
return `${date.getFullYear()}-${month}-${day}`
Expand All @@ -36,7 +36,7 @@ export function formatDate(date) {
}

export function formatDateTime(date) {
if(date) {
if(date && date instanceof Date) {
const months = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : `${date.getMonth() + 1}`
const days = date.getDate() < 10 ? `0${date.getDate()}` : `${date.getDate()}`
const hours = date.getHours() < 10 ? `0${date.getHours()}` : `${date.getHours()}`
Expand Down Expand Up @@ -104,7 +104,7 @@ export function copyError(error) {
Object.keys(error.params).forEach(paramName => {
const param = error.params[paramName]
if (Array.isArray(param)) params[paramName] = copyArray(param)
else if (param instanceof FileList) params[paramName] = copyFiles(param)
else if (typeof param.item === 'function') params[paramName] = copyFiles(param)
else params[paramName] = param
})
output.params = params
Expand Down

0 comments on commit ccd70a7

Please sign in to comment.