Skip to content

Commit 419d9da

Browse files
crisbetoandrewseguin
authored andcommitted
test(datepicker): set locale to en-US (#5049)
Currently, some of the datepicker tests will fail if the browser's locale is different from en-US. These changes set the locale to en-US in order to avoid potential issues in the future.
1 parent 6b659ee commit 419d9da

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/lib/datepicker/datepicker.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {By} from '@angular/platform-browser';
88
import {dispatchFakeEvent, dispatchMouseEvent} from '../core/testing/dispatch-events';
99
import {MdInputModule} from '../input/index';
1010
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
11-
import {MdNativeDateModule} from '../core/datetime/index';
11+
import {MdNativeDateModule, DateAdapter, NativeDateAdapter} from '../core/datetime/index';
1212

1313

1414
// When constructing a Date, the month is zero-based. This can be confusing, since people are
@@ -29,6 +29,13 @@ describe('MdDatepicker', () => {
2929
NoopAnimationsModule,
3030
ReactiveFormsModule,
3131
],
32+
providers: [
33+
{provide: DateAdapter, useFactory: () => {
34+
let adapter = new NativeDateAdapter();
35+
adapter.setLocale('en-US');
36+
return adapter;
37+
}}
38+
],
3239
declarations: [
3340
DatepickerWithFilterAndValidation,
3441
DatepickerWithFormControl,

src/lib/datepicker/month-view.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Component} from '@angular/core';
33
import {By} from '@angular/platform-browser';
44
import {MdMonthView} from './month-view';
55
import {MdCalendarBody} from './calendar-body';
6-
import {MdNativeDateModule} from '../core/datetime/index';
6+
import {MdNativeDateModule, DateAdapter, NativeDateAdapter} from '../core/datetime/index';
77

88

99
// When constructing a Date, the month is zero-based. This can be confusing, since people are
@@ -18,6 +18,13 @@ describe('MdMonthView', () => {
1818
imports: [
1919
MdNativeDateModule,
2020
],
21+
providers: [
22+
{provide: DateAdapter, useFactory: () => {
23+
let adapter = new NativeDateAdapter();
24+
adapter.setLocale('en-US');
25+
return adapter;
26+
}}
27+
],
2128
declarations: [
2229
MdCalendarBody,
2330
MdMonthView,

src/lib/datepicker/year-view.spec.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Component} from '@angular/core';
33
import {By} from '@angular/platform-browser';
44
import {MdYearView} from './year-view';
55
import {MdCalendarBody} from './calendar-body';
6-
import {MdNativeDateModule} from '../core/datetime/index';
6+
import {MdNativeDateModule, DateAdapter, NativeDateAdapter} from '../core/datetime/index';
77

88

99
// When constructing a Date, the month is zero-based. This can be confusing, since people are
@@ -18,6 +18,13 @@ describe('MdYearView', () => {
1818
imports: [
1919
MdNativeDateModule,
2020
],
21+
providers: [
22+
{provide: DateAdapter, useFactory: () => {
23+
let adapter = new NativeDateAdapter();
24+
adapter.setLocale('en-US');
25+
return adapter;
26+
}}
27+
],
2128
declarations: [
2229
MdCalendarBody,
2330
MdYearView,

0 commit comments

Comments
 (0)