mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-12 02:23:49 +00:00
Removed no longer needed async/await when building api client
This commit is contained in:
@@ -38,7 +38,7 @@ describe('selectedServerReducer', () => {
|
||||
const apiClientMock = {
|
||||
health: jest.fn(),
|
||||
};
|
||||
const buildApiClient = jest.fn().mockResolvedValue(apiClientMock);
|
||||
const buildApiClient = jest.fn().mockReturnValue(apiClientMock);
|
||||
const dispatch = jest.fn();
|
||||
|
||||
afterEach(jest.clearAllMocks);
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('shortUrlMetaReducer', () => {
|
||||
|
||||
describe('editShortUrlMeta', () => {
|
||||
const updateShortUrlMeta = jest.fn().mockResolvedValue({});
|
||||
const buildShlinkApiClient = jest.fn().mockResolvedValue({ updateShortUrlMeta });
|
||||
const buildShlinkApiClient = jest.fn().mockReturnValue({ updateShortUrlMeta });
|
||||
const dispatch = jest.fn();
|
||||
|
||||
afterEach(jest.clearAllMocks);
|
||||
|
||||
@@ -51,14 +51,10 @@ describe('shortUrlTagsReducer', () => {
|
||||
|
||||
describe('editShortUrlTags', () => {
|
||||
const updateShortUrlTags = jest.fn();
|
||||
const buildShlinkApiClient = jest.fn().mockResolvedValue({ updateShortUrlTags });
|
||||
const buildShlinkApiClient = jest.fn().mockReturnValue({ updateShortUrlTags });
|
||||
const dispatch = jest.fn();
|
||||
|
||||
afterEach(() => {
|
||||
updateShortUrlTags.mockReset();
|
||||
buildShlinkApiClient.mockClear();
|
||||
dispatch.mockReset();
|
||||
});
|
||||
afterEach(jest.clearAllMocks);
|
||||
|
||||
it.each([[ undefined ], [ null ], [ 'example.com' ]])('dispatches normalized tags on success', async (domain) => {
|
||||
const normalizedTags = [ 'bar', 'foo' ];
|
||||
|
||||
@@ -104,7 +104,7 @@ describe('tagsListReducer', () => {
|
||||
const tags = [ 'foo', 'bar', 'baz' ];
|
||||
|
||||
listTagsMock.mockResolvedValue(tags);
|
||||
buildShlinkApiClient.mockResolvedValue({ listTags: listTagsMock });
|
||||
buildShlinkApiClient.mockReturnValue({ listTags: listTagsMock });
|
||||
|
||||
await listTags(buildShlinkApiClient, true)()(dispatch, getState);
|
||||
|
||||
@@ -127,7 +127,7 @@ describe('tagsListReducer', () => {
|
||||
|
||||
it('dispatches error when error occurs on list call', async () => {
|
||||
listTagsMock.mockRejectedValue(new Error());
|
||||
buildShlinkApiClient.mockResolvedValue({ listTags: listTagsMock });
|
||||
buildShlinkApiClient.mockReturnValue({ listTags: listTagsMock });
|
||||
|
||||
await assertErrorResult();
|
||||
|
||||
@@ -135,7 +135,9 @@ describe('tagsListReducer', () => {
|
||||
});
|
||||
|
||||
it('dispatches error when error occurs on build call', async () => {
|
||||
buildShlinkApiClient.mockRejectedValue(new Error());
|
||||
buildShlinkApiClient.mockImplementation(() => {
|
||||
throw new Error();
|
||||
});
|
||||
|
||||
await assertErrorResult();
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ describe('ShlinkApiClientBuilder', () => {
|
||||
expect(secondApiClient).toBe(thirdApiClient);
|
||||
});
|
||||
|
||||
it('does not fetch from state when provided param is already selected server', async () => {
|
||||
it('does not fetch from state when provided param is already selected server', () => {
|
||||
const url = 'url';
|
||||
const apiKey = 'apiKey';
|
||||
const apiClient = await buildShlinkApiClient({})({ url, apiKey });
|
||||
const apiClient = buildShlinkApiClient({})({ url, apiKey });
|
||||
|
||||
expect(apiClient._baseUrl).toEqual(url);
|
||||
expect(apiClient._apiKey).toEqual(apiKey);
|
||||
|
||||
Reference in New Issue
Block a user