mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-12 10:33:49 +00:00
Ensured domain is dispatched when modifying a short URL somehow
This commit is contained in:
@@ -72,7 +72,7 @@ describe('shortUrlDeletionReducer', () => {
|
||||
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: DELETE_SHORT_URL_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_DELETED, shortCode });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_DELETED, shortCode, domain });
|
||||
|
||||
expect(apiClientMock.deleteShortUrl).toHaveBeenCalledTimes(1);
|
||||
expect(apiClientMock.deleteShortUrl).toHaveBeenCalledWith(shortCode, domain);
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('shortUrlMetaReducer', () => {
|
||||
expect(updateShortUrlMeta).toHaveBeenCalledWith(shortCode, domain, meta);
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: EDIT_SHORT_URL_META_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_META_EDITED, meta, shortCode });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_META_EDITED, meta, shortCode, domain });
|
||||
});
|
||||
|
||||
it('dispatches error on failure', async () => {
|
||||
|
||||
@@ -73,7 +73,10 @@ describe('shortUrlTagsReducer', () => {
|
||||
expect(updateShortUrlTags).toHaveBeenCalledWith(shortCode, domain, tags);
|
||||
expect(dispatch).toHaveBeenCalledTimes(2);
|
||||
expect(dispatch).toHaveBeenNthCalledWith(1, { type: EDIT_SHORT_URL_TAGS_START });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(2, { type: SHORT_URL_TAGS_EDITED, tags: normalizedTags, shortCode });
|
||||
expect(dispatch).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
{ type: SHORT_URL_TAGS_EDITED, tags: normalizedTags, shortCode, domain }
|
||||
);
|
||||
});
|
||||
|
||||
it('dispatches error on failure', async () => {
|
||||
|
||||
@@ -38,15 +38,17 @@ describe('shortUrlsListReducer', () => {
|
||||
shortUrls: {
|
||||
data: [
|
||||
{ shortCode, tags: [] },
|
||||
{ shortCode, tags: [], domain: 'example.com' },
|
||||
{ shortCode: 'foo', tags: [] },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
expect(reducer(state, { type: SHORT_URL_TAGS_EDITED, shortCode, tags })).toEqual({
|
||||
expect(reducer(state, { type: SHORT_URL_TAGS_EDITED, shortCode, tags, domain: null })).toEqual({
|
||||
shortUrls: {
|
||||
data: [
|
||||
{ shortCode, tags },
|
||||
{ shortCode, tags: [], domain: 'example.com' },
|
||||
{ shortCode: 'foo', tags: [] },
|
||||
],
|
||||
},
|
||||
@@ -55,6 +57,7 @@ describe('shortUrlsListReducer', () => {
|
||||
|
||||
it('Updates meta on matching URL on SHORT_URL_META_EDITED', () => {
|
||||
const shortCode = 'abc123';
|
||||
const domain = 'example.com';
|
||||
const meta = {
|
||||
maxVisits: 5,
|
||||
validSince: '2020-05-05',
|
||||
@@ -62,16 +65,18 @@ describe('shortUrlsListReducer', () => {
|
||||
const state = {
|
||||
shortUrls: {
|
||||
data: [
|
||||
{ shortCode, meta: { maxVisits: 10 } },
|
||||
{ shortCode, meta: { maxVisits: 10 }, domain },
|
||||
{ shortCode, meta: { maxVisits: 50 } },
|
||||
{ shortCode: 'foo', meta: null },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
expect(reducer(state, { type: SHORT_URL_META_EDITED, shortCode, meta })).toEqual({
|
||||
expect(reducer(state, { type: SHORT_URL_META_EDITED, shortCode, meta, domain })).toEqual({
|
||||
shortUrls: {
|
||||
data: [
|
||||
{ shortCode, meta },
|
||||
{ shortCode, meta, domain: 'example.com' },
|
||||
{ shortCode, meta: { maxVisits: 50 } },
|
||||
{ shortCode: 'foo', meta: null },
|
||||
],
|
||||
},
|
||||
@@ -84,6 +89,7 @@ describe('shortUrlsListReducer', () => {
|
||||
shortUrls: {
|
||||
data: [
|
||||
{ shortCode },
|
||||
{ shortCode, domain: 'example.com' },
|
||||
{ shortCode: 'foo' },
|
||||
],
|
||||
},
|
||||
@@ -91,7 +97,7 @@ describe('shortUrlsListReducer', () => {
|
||||
|
||||
expect(reducer(state, { type: SHORT_URL_DELETED, shortCode })).toEqual({
|
||||
shortUrls: {
|
||||
data: [{ shortCode: 'foo' }],
|
||||
data: [{ shortCode, domain: 'example.com' }, { shortCode: 'foo' }],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user