Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit d2ef77c

Browse files
alisahinozcelikdoom777
authored andcommitted
fix: Language config bug fixed (#1775)
language config was not working when it is set in forRoot method
1 parent 4c9e977 commit d2ef77c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

packages/core/services/maps-api-loader/lazy-maps-api-loader.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,31 @@ describe('Service: LazyMapsAPILoader', () => {
130130
const url = new URL(scriptElem.src);
131131
expect(url.searchParams.get('language')).toEqual('es');
132132
});
133+
134+
it('should load language based on config', () => {
135+
TestBed.configureTestingModule({
136+
providers: [
137+
{provide: MapsAPILoader, useClass: LazyMapsAPILoader},
138+
{provide: WindowRef, useValue: windowRef},
139+
{provide: DocumentRef, useValue: documentRef},
140+
{provide: LAZY_MAPS_API_CONFIG, useValue: {language: 'tr'} as LazyMapsAPILoaderConfigLiteral},
141+
{provide: LOCALE_ID, useValue: 'es'},
142+
],
143+
});
144+
145+
const loader: LazyMapsAPILoader = TestBed.get(MapsAPILoader);
146+
interface Script {
147+
src?: string;
148+
async?: boolean;
149+
defer?: boolean;
150+
type?: string;
151+
}
152+
const scriptElem: Script = {};
153+
(doc.createElement as jest.Mock).mockReturnValue(scriptElem);
154+
155+
loader.load();
156+
expect(doc.createElement).toHaveBeenCalled();
157+
const url = new URL(scriptElem.src);
158+
expect(url.searchParams.get('language')).toEqual('tr');
159+
});
133160
});

packages/core/services/maps-api-loader/lazy-maps-api-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class LazyMapsAPILoader extends MapsAPILoader {
162162
channel: this._config.channel,
163163
libraries: this._config.libraries,
164164
region: this._config.region,
165-
language: this._config.language || this.localeId !== 'en-US' ? this.localeId : null,
165+
language: this._config.language || (this.localeId !== 'en-US' ? this.localeId : null),
166166
};
167167
const params: string = Object.keys(queryParams)
168168
.filter((k: string) => queryParams[k] != null)

0 commit comments

Comments
 (0)