1- import { spanishToday , spanishTomorrow , isoToday , isoTomorrow , spanishFromIso } from '../date-utils'
1+ import {
2+ localizedToday , englishToday , isoToday , isoTomorrow , localizedFromIso , localizedTomorrow ,
3+ setLocale
4+ } from '../date-utils'
25import { stubNow } from '../../../../test/helpers'
36
47describe ( 'date utils' , ( ) => {
@@ -13,16 +16,34 @@ describe('date utils', () => {
1316 expect ( isoTomorrow ( ) ) . toBe ( '2017-09-19' )
1417 } )
1518
16- it ( 'Prints todays date in spanish ', ( ) => {
17- expect ( spanishToday ( ) ) . toBe ( 'Lunes, 18 de Septiembre' )
18- } )
19+ describe ( 'When locale is english ', ( ) => {
20+
21+ beforeEach ( ( ) => setLocale ( 'en' ) )
1922
20- it ( 'Prints tomorrows date in spanish' , ( ) => {
21- expect ( spanishTomorrow ( ) ) . toBe ( 'Martes, 19 de Septiembre' )
23+ it ( 'Prints todays date' , ( ) => {
24+ expect ( localizedToday ( ) ) . toBe ( 'Monday, 18 Of September' )
25+ } )
26+
27+ it ( 'Prints tomorrows date' , ( ) => {
28+ expect ( localizedTomorrow ( ) ) . toBe ( 'Tuesday, 19 Of September' )
29+ } )
2230 } )
2331
24- it ( 'translate ISO date to Spanish format' , ( ) => {
25- expect ( spanishFromIso ( '2017-09-18' ) ) . toBe ( 'Lunes, 18 de Septiembre' )
26- expect ( spanishFromIso ( '2017-11-04' ) ) . toBe ( 'Sábado, 04 de Noviembre' )
32+ describe ( 'When locale is spanish' , ( ) => {
33+
34+ beforeEach ( ( ) => setLocale ( 'es' ) )
35+
36+ it ( 'Prints todays date' , ( ) => {
37+ expect ( localizedToday ( ) ) . toBe ( 'Lunes, 18 De Septiembre' )
38+ } )
39+
40+ it ( 'Prints tomorrows date' , ( ) => {
41+ expect ( localizedTomorrow ( ) ) . toBe ( 'Martes, 19 De Septiembre' )
42+ } )
43+
44+ it ( 'translate ISO date' , ( ) => {
45+ expect ( localizedFromIso ( '2017-09-18' ) ) . toBe ( 'Lunes, 18 De Septiembre' )
46+ expect ( localizedFromIso ( '2017-11-04' ) ) . toBe ( 'Sábado, 04 De Noviembre' )
47+ } )
2748 } )
2849} )
0 commit comments