File tree Expand file tree Collapse file tree 7 files changed +32
-20
lines changed Expand file tree Collapse file tree 7 files changed +32
-20
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { Link } from 'react-router'
44import VisitService from 'services/Visit'
55import Error from 'components/Error/Error'
66import styles from 'components/Visit/Show/styles.css'
7- import DateHelper from 'helpers/DateHelper '
7+ import DateHelper from 'helpers/Date '
88
99class Visit extends React . Component
1010{
@@ -51,7 +51,7 @@ class Visit extends React.Component
5151 < strong > { this . state . visit . client . name } </ strong >
5252 </ h3 >
5353 < p className = "tagline" >
54- < strong > Visit Date: </ strong > { DateHelper . formateDate ( this . state . visit . visit_date ) }
54+ < strong > Visit Date: </ strong > { DateHelper . format ( this . state . visit . visit_date ) }
5555 </ p >
5656 < p className = "tagline" >
5757 < strong > Address: </ strong > { this . state . visit . client . address }
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import { Link } from 'react-router'
3+ import DateHelper from 'helpers/Date'
34
45class Visit extends React . Component
56{
@@ -15,7 +16,7 @@ class Visit extends React.Component
1516 return this . state . visits . map ( ( areaVisit , key ) => (
1617 < tr key = { key } >
1718 < td > { areaVisit . visit . client . name } </ td >
18- < td > { areaVisit . visit . visit_date } </ td >
19+ < td > { DateHelper . format ( areaVisit . visit . visit_date ) } </ td >
1920 < td className = "is-icon" >
2021 < Link to = { `/visit/${ areaVisit . visit . _id } ` } >
2122 < i className = "fa fa-info-circle" />
Original file line number Diff line number Diff line change 1+ const Date = {
2+ format ( date ) {
3+ let dateObj = new window . Date ( date ) ;
4+ let options = {
5+ day : '2-digit' ,
6+ month : '2-digit' ,
7+ year : 'numeric'
8+ }
9+ return dateObj . toGMTString ( ) ;
10+ }
11+ }
12+
13+ export default Date ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+
2+ describe ( 'Test DateHelper' , ( ) => {
3+
4+ const DateHelper = require ( 'helpers/Date' ) . default ;
5+
6+ it ( 'should return date on format GMT' , ( done ) => {
7+ let date = DateHelper . format ( '2016-10-19T13:30:13.329Z' ) ;
8+ expect ( date ) . toEqual ( "Wed, 19 Oct 2016 13:30:13 GMT" ) ;
9+ done ( ) ;
10+ } ) ;
11+ } ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ jest.dontMock('axios');
77jest . dontMock ( 'axios-mock-adapter' ) ;
88jest . dontMock ( 'enzyme' ) ;
99jest . dontMock ( 'services/Visit' ) ;
10- jest . dontMock ( 'helpers/DateHelper ' ) ;
10+ jest . dontMock ( 'helpers/Date ' ) ;
1111
1212describe ( 'Test Visit' , ( ) => {
1313 require ( '../tests/__mocks__/LocalStorageMock' ) ;
@@ -57,7 +57,7 @@ describe('Test Visit', () => {
5757 setTimeout ( ( ) => {
5858
5959 try {
60- expect ( component . find ( '.name p' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Visit Date: 10/01/ 2017' ) ;
60+ expect ( component . find ( '.name p' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Visit Date: Sun, 01 Oct 2017 00:00:00 GMT ' ) ;
6161 expect ( component . find ( '.name p' ) . at ( 1 ) . text ( ) ) . toEqual ( 'Address: 7 Street' ) ;
6262 expect ( component . find ( '.name p' ) . at ( 2 ) . text ( ) ) . toEqual ( 'Area: Center' ) ;
6363 expect ( component . find ( '.followers p' ) . at ( 0 ) . text ( ) ) . toEqual ( 'R$ 300' ) ;
Original file line number Diff line number Diff line change @@ -53,11 +53,11 @@ describe('Test Visit', () => {
5353
5454 expect ( component . find ( 'td' ) . length ) . toEqual ( 6 ) ;
5555 expect ( component . find ( 'td' ) . at ( 0 ) . text ( ) ) . toEqual ( 'Jon Snow' ) ;
56- expect ( component . find ( 'td' ) . at ( 1 ) . text ( ) ) . toEqual ( '2016-10-19T13 :30:13.329Z ' ) ;
56+ expect ( component . find ( 'td' ) . at ( 1 ) . text ( ) ) . toEqual ( 'Wed, 19 Oct 2016 13 :30:13 GMT ' ) ;
5757 expect ( component . find ( 'td' ) . at ( 2 ) . text ( ) ) . toEqual ( '<Link />' ) ;
5858
5959 expect ( component . find ( 'td' ) . at ( 3 ) . text ( ) ) . toEqual ( 'Cotter Pyke' ) ;
60- expect ( component . find ( 'td' ) . at ( 4 ) . text ( ) ) . toEqual ( '2016-10-18T13 :31:14.430Z ' ) ;
60+ expect ( component . find ( 'td' ) . at ( 4 ) . text ( ) ) . toEqual ( 'Tue, 18 Oct 2016 13 :31:14 GMT ' ) ;
6161 expect ( component . find ( 'td' ) . at ( 5 ) . text ( ) ) . toEqual ( '<Link />' ) ;
6262 done ( ) ;
6363 } ) ;
You can’t perform that action at this time.
0 commit comments