mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-15 03:53:51 +00:00
Migrated deleteShortUrl action creator to use PayloadAction and have a single param
This commit is contained in:
@@ -27,7 +27,10 @@ describe('shortUrlDeletionReducer', () => {
|
||||
}));
|
||||
|
||||
it('returns shortCode on SHORT_URL_DELETED', () =>
|
||||
expect(reducer(undefined, { type: SHORT_URL_DELETED, shortCode: 'foo' } as any)).toEqual({
|
||||
expect(reducer(undefined, {
|
||||
type: SHORT_URL_DELETED,
|
||||
payload: { shortCode: 'foo' },
|
||||
} as any)).toEqual({
|
||||
shortCode: 'foo',
|
||||
loading: false,
|
||||
error: false,
|
||||
@@ -67,11 +70,14 @@ describe('shortUrlDeletionReducer', () => {
|
||||
});
|
||||
const shortCode = 'abc123';
|
||||
|
||||
await deleteShortUrl(() => apiClientMock)(shortCode, domain)(dispatch, getState);
|
||||
await deleteShortUrl(() => apiClientMock)({ shortCode, domain })(dispatch, getState);
|
||||
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: DELETE_SHORT_URL_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_DELETED, shortCode, domain });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, {
|
||||
type: SHORT_URL_DELETED,
|
||||
payload: { shortCode, domain },
|
||||
});
|
||||
|
||||
expect(apiClientMock.deleteShortUrl).toHaveBeenCalledTimes(1);
|
||||
expect(apiClientMock.deleteShortUrl).toHaveBeenCalledWith(shortCode, domain);
|
||||
@@ -86,7 +92,7 @@ describe('shortUrlDeletionReducer', () => {
|
||||
const shortCode = 'abc123';
|
||||
|
||||
try {
|
||||
await deleteShortUrl(() => apiClientMock)(shortCode)(dispatch, getState);
|
||||
await deleteShortUrl(() => apiClientMock)({ shortCode })(dispatch, getState);
|
||||
} catch (e) {
|
||||
expect(e).toEqual(error);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ describe('shortUrlsListReducer', () => {
|
||||
error: false,
|
||||
};
|
||||
|
||||
expect(reducer(state, { type: SHORT_URL_DELETED, shortCode } as any)).toEqual({
|
||||
expect(reducer(state, { type: SHORT_URL_DELETED, payload: { shortCode } } as any)).toEqual({
|
||||
shortUrls: {
|
||||
data: [{ shortCode, domain: 'example.com' }, { shortCode: 'foo' }],
|
||||
pagination: { totalItems: 9 },
|
||||
|
||||
Reference in New Issue
Block a user