Dropped support to send tags to the PATCH endpoint

This commit is contained in:
Alejandro Celaya
2022-05-01 10:30:51 +02:00
parent 5a0d67e409
commit 9518ad9bb4
5 changed files with 4 additions and 61 deletions

View File

@@ -156,25 +156,6 @@ describe('ShlinkApiClient', () => {
});
});
describe('updateShortUrlTags', () => {
it.each(shortCodesWithDomainCombinations)('properly updates short URL tags', async (shortCode, domain) => {
const expectedTags = ['foo', 'bar'];
const axiosSpy = createAxiosMock({
data: { tags: expectedTags },
});
const { updateShortUrlTags } = new ShlinkApiClient(axiosSpy, '', '');
const result = await updateShortUrlTags(shortCode, domain, expectedTags);
expect(expectedTags).toEqual(result);
expect(axiosSpy).toHaveBeenCalledWith(expect.objectContaining({
url: `/short-urls/${shortCode}/tags`,
method: 'PUT',
params: domain ? { domain } : {},
}));
});
});
describe('updateShortUrl', () => {
it.each(shortCodesWithDomainCombinations)('properly updates short URL meta', async (shortCode, domain) => {
const meta = {

View File

@@ -8,7 +8,7 @@ import reducer, {
} from '../../../src/short-urls/reducers/shortUrlEdition';
import { ShlinkState } from '../../../src/container/types';
import { ShortUrl } from '../../../src/short-urls/data';
import { ReachableServer, SelectedServer } from '../../../src/servers/data';
import { SelectedServer } from '../../../src/servers/data';
describe('shortUrlEditionReducer', () => {
const longUrl = 'https://shlink.io';
@@ -41,8 +41,7 @@ describe('shortUrlEditionReducer', () => {
describe('editShortUrl', () => {
const updateShortUrl = jest.fn().mockResolvedValue(shortUrl);
const updateShortUrlTags = jest.fn().mockResolvedValue([]);
const buildShlinkApiClient = jest.fn().mockReturnValue({ updateShortUrl, updateShortUrlTags });
const buildShlinkApiClient = jest.fn().mockReturnValue({ updateShortUrl });
const dispatch = jest.fn();
const createGetState = (selectedServer: SelectedServer = null) => () => Mock.of<ShlinkState>({ selectedServer });
@@ -59,25 +58,6 @@ describe('shortUrlEditionReducer', () => {
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_EDITED, shortUrl });
});
it.each([
[null, { tags: ['foo', 'bar'] }, 1],
[null, {}, 0],
[Mock.of<ReachableServer>({ version: '2.6.0' }), {}, 0],
[Mock.of<ReachableServer>({ version: '2.6.0' }), { tags: ['foo', 'bar'] }, 0],
[Mock.of<ReachableServer>({ version: '2.5.0' }), {}, 0],
[Mock.of<ReachableServer>({ version: '2.5.0' }), { tags: ['foo', 'bar'] }, 1],
])(
'sends tags separately when appropriate, based on selected server and the payload',
async (server, payload, expectedTagsCalls) => {
const getState = createGetState(server);
await editShortUrl(buildShlinkApiClient)(shortCode, null, payload)(dispatch, getState);
expect(updateShortUrl).toHaveBeenCalled();
expect(updateShortUrlTags).toHaveBeenCalledTimes(expectedTagsCalls);
},
);
it('dispatches error on failure', async () => {
const error = new Error();