Skip to content

Commit

Permalink
Merge pull request #1445 from acelaya-forks/feature/js-sdk-2.0
Browse files Browse the repository at this point in the history
Update to JS SDK 2.0 and shlink-web-component 0.13
  • Loading branch information
acelaya authored Feb 11, 2025
2 parents db13d43 + d2d9810 commit c85917e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 37 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Changed
* Update to `react-router` 7.0
* Update to `@shlinkio/shlink-frontend-kit` 0.7.0
* Update to `@shlinkio/shlink-web-component` 0.12.0
* Update to `@shlinkio/shlink-web-component` 0.13.0
* Update to `@shlinkio/shlink-js-sdk` 2.0.0

### Deprecated
* *Nothing*
Expand Down
55 changes: 28 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@reduxjs/toolkit": "^2.5.1",
"@shlinkio/data-manipulation": "^1.0.3",
"@shlinkio/shlink-frontend-kit": "^0.7.2",
"@shlinkio/shlink-js-sdk": "^1.4.0",
"@shlinkio/shlink-web-component": "^0.12.1",
"@shlinkio/shlink-js-sdk": "^2.0.0",
"@shlinkio/shlink-web-component": "^0.13.0",
"bootstrap": "5.2.3",
"bottlejs": "^2.0.1",
"clsx": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/common/services/provideServices.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/browser';
import { FetchHttpClient } from '@shlinkio/shlink-js-sdk/fetch';
import { ShlinkWebComponent } from '@shlinkio/shlink-web-component';
import type Bottle from 'bottlejs';
import type { ConnectDecorator } from '../../container/types';
Expand Down
20 changes: 14 additions & 6 deletions test/api/services/ShlinkApiClientBuilder.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { HttpClient } from '@shlinkio/shlink-js-sdk';
import { fromPartial } from '@total-typescript/shoehorn';
import { buildShlinkApiClient } from '../../../src/api/services/ShlinkApiClientBuilder';
import type { ReachableServer, SelectedServer } from '../../../src/servers/data';
Expand Down Expand Up @@ -34,12 +35,19 @@ describe('ShlinkApiClientBuilder', () => {
expect(secondApiClient === thirdApiClient).toEqual(true);
});

it('does not fetch from state when provided param is already selected server', () => {
const url = 'url';
const apiKey = 'apiKey';
const apiClient = buildShlinkApiClient(fromPartial({}))(server({ url, apiKey }));
it.only('does not fetch from state when provided param is already selected server', async () => {
const url = 'the_url';
const apiKey = 'the_api_key';
const jsonRequest = vi.fn();
const httpClient = fromPartial<HttpClient>({ jsonRequest });
const apiClient = buildShlinkApiClient(httpClient)(server({ url, apiKey }));

expect(apiClient['serverInfo'].baseUrl).toEqual(url);
expect(apiClient['serverInfo'].apiKey).toEqual(apiKey);
await apiClient.health();

expect(jsonRequest).toHaveBeenCalledWith(expect.stringMatching(new RegExp(`^${url}`)), expect.objectContaining({
headers: {
'X-Api-Key': apiKey,
},
}));
});
});

0 comments on commit c85917e

Please sign in to comment.