@@ -10,156 +10,14 @@ import {MomentDateAdapter} from './moment-date-adapter';
1010import { async , inject , TestBed } from '@angular/core/testing' ;
1111import { MomentDateModule } from './index' ;
1212import { DateAdapter , MAT_DATE_LOCALE } from '@angular/material' ;
13- import * as moment from 'moment' ;
1413import { LOCALE_ID } from '@angular/core' ;
14+ import * as moment from 'moment' ;
1515
1616
1717// Month constants for more readable tests.
1818const JAN = 0 , FEB = 1 , MAR = 2 , DEC = 11 ;
1919
2020
21- // Add some locales for testing. These definitions come from Moment.js's fr.js and ja.js locale
22- // files. (We don't want to the version of moment that comes with locales because it's a lot of
23- // extra bytes to include in our tests.)
24- moment . defineLocale ( 'fr' , {
25- months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'
26- . split ( '_' ) ,
27- monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.' . split ( '_' ) ,
28- monthsParseExact : true ,
29- weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi' . split ( '_' ) ,
30- weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.' . split ( '_' ) ,
31- weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa' . split ( '_' ) ,
32- weekdaysParseExact : true ,
33- longDateFormat : {
34- LT : 'HH:mm' ,
35- LTS : 'HH:mm:ss' ,
36- L : 'DD/MM/YYYY' ,
37- LL : 'D MMMM YYYY' ,
38- LLL : 'D MMMM YYYY HH:mm' ,
39- LLLL : 'dddd D MMMM YYYY HH:mm'
40- } ,
41- calendar : {
42- sameDay : '[Aujourd’hui à] LT' ,
43- nextDay : '[Demain à] LT' ,
44- nextWeek : 'dddd [à] LT' ,
45- lastDay : '[Hier à] LT' ,
46- lastWeek : 'dddd [dernier à] LT' ,
47- sameElse : 'L'
48- } ,
49- relativeTime : {
50- future : 'dans %s' ,
51- past : 'il y a %s' ,
52- s : 'quelques secondes' ,
53- m : 'une minute' ,
54- mm : '%d minutes' ,
55- h : 'une heure' ,
56- hh : '%d heures' ,
57- d : 'un jour' ,
58- dd : '%d jours' ,
59- M : 'un mois' ,
60- MM : '%d mois' ,
61- y : 'un an' ,
62- yy : '%d ans'
63- } ,
64- dayOfMonthOrdinalParse : / \d { 1 , 2 } ( e r | ) / ,
65- // tslint:disable-next-line:variable-name
66- ordinal : function ( number , period ) {
67- switch ( period ) {
68- // TODO: Return 'e' when day of month > 1. Move this case inside
69- // block for masculine words below.
70- // See https://github.com/moment/moment/issues/3375
71- case 'D' :
72- return number + ( number === 1 ? 'er' : '' ) ;
73-
74- // Words with masculine grammatical gender: mois, trimestre, jour
75- default :
76- case 'M' :
77- case 'Q' :
78- case 'DDD' :
79- case 'd' :
80- return number + ( number === 1 ? 'er' : 'e' ) ;
81-
82- // Words with feminine grammatical gender: semaine
83- case 'w' :
84- case 'W' :
85- return number + ( number === 1 ? 're' : 'e' ) ;
86- }
87- } ,
88- week : {
89- dow : 1 , // Monday is the first day of the week.
90- doy : 4 // The week that contains Jan 4th is the first week of the year.
91- }
92- } as any ) ;
93-
94- moment . defineLocale ( 'ja' , {
95- months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月' . split ( '_' ) ,
96- monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月' . split ( '_' ) ,
97- weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日' . split ( '_' ) ,
98- weekdaysShort : '日_月_火_水_木_金_土' . split ( '_' ) ,
99- weekdaysMin : '日_月_火_水_木_金_土' . split ( '_' ) ,
100- longDateFormat : {
101- LT : 'HH:mm' ,
102- LTS : 'HH:mm:ss' ,
103- L : 'YYYY/MM/DD' ,
104- LL : 'YYYY年M月D日' ,
105- LLL : 'YYYY年M月D日 HH:mm' ,
106- LLLL : 'YYYY年M月D日 HH:mm dddd' ,
107- l : 'YYYY/MM/DD' ,
108- ll : 'YYYY年M月D日' ,
109- lll : 'YYYY年M月D日 HH:mm' ,
110- llll : 'YYYY年M月D日 HH:mm dddd'
111- } ,
112- meridiemParse : / 午 前 | 午 後 / i,
113- isPM : function ( input ) {
114- return input === '午後' ;
115- } ,
116- meridiem : function ( hour ) {
117- if ( hour < 12 ) {
118- return '午前' ;
119- } else {
120- return '午後' ;
121- }
122- } ,
123- calendar : {
124- sameDay : '[今日] LT' ,
125- nextDay : '[明日] LT' ,
126- nextWeek : '[来週]dddd LT' ,
127- lastDay : '[昨日] LT' ,
128- lastWeek : '[前週]dddd LT' ,
129- sameElse : 'L'
130- } ,
131- dayOfMonthOrdinalParse : / \d { 1 , 2 } 日 / ,
132- // tslint:disable-next-line:variable-name
133- ordinal : function ( number , period ) {
134- switch ( period ) {
135- case 'd' :
136- case 'D' :
137- case 'DDD' :
138- return number + '日' ;
139- default :
140- return number ;
141- }
142- } ,
143- relativeTime : {
144- future : '%s後' ,
145- past : '%s前' ,
146- s : '数秒' ,
147- m : '1分' ,
148- mm : '%d分' ,
149- h : '1時間' ,
150- hh : '%d時間' ,
151- d : '1日' ,
152- dd : '%d日' ,
153- M : '1ヶ月' ,
154- MM : '%dヶ月' ,
155- y : '1年' ,
156- yy : '%d年'
157- }
158- } as any ) ;
159-
160- moment . locale ( 'en' ) ;
161-
162-
16321describe ( 'MomentDateAdapter' , ( ) => {
16422 let adapter : MomentDateAdapter ;
16523
@@ -170,6 +28,7 @@ describe('MomentDateAdapter', () => {
17028 } ) ) ;
17129
17230 beforeEach ( inject ( [ DateAdapter ] , ( d : MomentDateAdapter ) => {
31+ moment . locale ( 'en' ) ;
17332 adapter = d ;
17433 adapter . setLocale ( 'en' ) ;
17534 } ) ) ;
0 commit comments