11import { TestBed , async , inject } from '@angular/core/testing' ;
2- import { LOCALE_ID } from '@angular/core' ;
3- import { NativeDateAdapter , NativeDateModule , DateAdapter } from './index' ;
2+ import { NativeDateAdapter , NativeDateModule , DateAdapter , MAT_DATE_LOCALE } from './index' ;
43import { Platform } from '../platform/index' ;
54import { DEC , FEB , JAN , MAR } from '../testing/month-constants' ;
5+ import { LOCALE_ID } from '@angular/core' ;
66
77const SUPPORTS_INTL = typeof Intl != 'undefined' ;
88
@@ -334,6 +334,30 @@ describe('NativeDateAdapter', () => {
334334} ) ;
335335
336336
337+ describe ( 'NativeDateAdapter with MAT_DATE_LOCALE override' , ( ) => {
338+ let adapter : NativeDateAdapter ;
339+
340+ beforeEach ( async ( ( ) => {
341+ TestBed . configureTestingModule ( {
342+ imports : [ NativeDateModule ] ,
343+ providers : [ { provide : MAT_DATE_LOCALE , useValue : 'da-DK' } ]
344+ } ) . compileComponents ( ) ;
345+ } ) ) ;
346+
347+ beforeEach ( inject ( [ DateAdapter ] , ( d : NativeDateAdapter ) => {
348+ adapter = d ;
349+ } ) ) ;
350+
351+ it ( 'should take the default locale id from the MAT_DATE_LOCALE injection token' , ( ) => {
352+ const expectedValue = SUPPORTS_INTL ?
353+ [ 'søndag' , 'mandag' , 'tirsdag' , 'onsdag' , 'torsdag' , 'fredag' , 'lørdag' ] :
354+ [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] ;
355+
356+ expect ( adapter . getDayOfWeekNames ( 'long' ) ) . toEqual ( expectedValue ) ;
357+ } ) ;
358+
359+ } ) ;
360+
337361describe ( 'NativeDateAdapter with LOCALE_ID override' , ( ) => {
338362 let adapter : NativeDateAdapter ;
339363
@@ -348,7 +372,7 @@ describe('NativeDateAdapter with LOCALE_ID override', () => {
348372 adapter = d ;
349373 } ) ) ;
350374
351- it ( 'should take the default locale id from the LOCALE_ID injection token' , ( ) => {
375+ it ( 'should cascade locale id from the LOCALE_ID injection token to MAT_DATE_LOCALE ' , ( ) => {
352376 const expectedValue = SUPPORTS_INTL ?
353377 [ 'søndag' , 'mandag' , 'tirsdag' , 'onsdag' , 'torsdag' , 'fredag' , 'lørdag' ] :
354378 [ 'Sunday' , 'Monday' , 'Tuesday' , 'Wednesday' , 'Thursday' , 'Friday' , 'Saturday' ] ;
0 commit comments