Skip to content

Commit

Permalink
fix: Language config bug fixed (#1775)
Browse files Browse the repository at this point in the history
language config was not working when it is set in forRoot method
  • Loading branch information
alisahinozcelik authored and doom777 committed Dec 4, 2019
1 parent 4c9e977 commit d2ef77c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,31 @@ describe('Service: LazyMapsAPILoader', () => {
const url = new URL(scriptElem.src);
expect(url.searchParams.get('language')).toEqual('es');
});

it('should load language based on config', () => {
TestBed.configureTestingModule({
providers: [
{provide: MapsAPILoader, useClass: LazyMapsAPILoader},
{provide: WindowRef, useValue: windowRef},
{provide: DocumentRef, useValue: documentRef},
{provide: LAZY_MAPS_API_CONFIG, useValue: {language: 'tr'} as LazyMapsAPILoaderConfigLiteral},
{provide: LOCALE_ID, useValue: 'es'},
],
});

const loader: LazyMapsAPILoader = TestBed.get(MapsAPILoader);
interface Script {
src?: string;
async?: boolean;
defer?: boolean;
type?: string;
}
const scriptElem: Script = {};
(doc.createElement as jest.Mock).mockReturnValue(scriptElem);

loader.load();
expect(doc.createElement).toHaveBeenCalled();
const url = new URL(scriptElem.src);
expect(url.searchParams.get('language')).toEqual('tr');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class LazyMapsAPILoader extends MapsAPILoader {
channel: this._config.channel,
libraries: this._config.libraries,
region: this._config.region,
language: this._config.language || this.localeId !== 'en-US' ? this.localeId : null,
language: this._config.language || (this.localeId !== 'en-US' ? this.localeId : null),
};
const params: string = Object.keys(queryParams)
.filter((k: string) => queryParams[k] != null)
Expand Down

2 comments on commit d2ef77c

@AhmedHashem94
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not working !!

@aakici
Copy link

@aakici aakici commented on d2ef77c Mar 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not working !!

same here.

Please sign in to comment.