Skip to content

Commit

Permalink
feat: throw error if version is v3 (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddubrava committed Nov 18, 2023
1 parent 2376317 commit f4c199a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Expand Up @@ -167,6 +167,23 @@ describe('YaApiLoaderService', () => {
fireScriptEvents();
});

it('should throw error if v3 version is used', (done) => {
const config: YaConfig = {
version: 'v3',
};

mockLoaderService(config);

service.load().subscribe({
error: (e) => {
expect(e).toBeInstanceOf(Error);
done();
},
});

fireScriptEvents();
});

it('should use ymaps from cache if it is defined', (done) => {
mockLoaderService();

Expand Down
Expand Up @@ -172,6 +172,12 @@ export class YaApiLoaderService {
const { enterprise, version, ...rest } = config;
const params = this.convertConfigIntoQueryParams(rest);

if (version === 'v3') {
throw new Error(
'Yandex.Maps API v3 is not supported, if you need it like this issue:\nhttps://github.com/ddubrava/angular8-yandex-maps/issues/226',
);
}

return `https://${enterprise ? 'enterprise.' : ''}api-maps.yandex.ru/${version}/?${params}`;
}

Expand Down

0 comments on commit f4c199a

Please sign in to comment.