Migrated editTag and tagEdited actions to use payload

This commit is contained in:
Alejandro Celaya
2022-11-07 21:45:33 +01:00
parent 5ecc791b38
commit f8fc1245ca
4 changed files with 39 additions and 17 deletions

View File

@@ -35,7 +35,10 @@ describe('tagEditReducer', () => {
});
it('returns tag names on EDIT_TAG', () => {
expect(reducer(undefined, { type: EDIT_TAG, oldName, newName, color })).toEqual({
expect(reducer(undefined, {
type: EDIT_TAG,
payload: { oldName, newName, color },
})).toEqual({
editing: false,
edited: true,
error: false,
@@ -49,9 +52,11 @@ describe('tagEditReducer', () => {
it('returns action based on provided params', () =>
expect(tagEdited('foo', 'bar', '#ff0000')).toEqual({
type: TAG_EDITED,
oldName: 'foo',
newName: 'bar',
color: '#ff0000',
payload: {
oldName: 'foo',
newName: 'bar',
color: '#ff0000',
},
}));
});
@@ -81,7 +86,10 @@ describe('tagEditReducer', () => {
expect(dispatch).toHaveBeenCalledTimes(2);
expect(dispatch).toHaveBeenNthCalledWith(1, { type: EDIT_TAG_START });
expect(dispatch).toHaveBeenNthCalledWith(2, { type: EDIT_TAG, oldName, newName, color });
expect(dispatch).toHaveBeenNthCalledWith(2, {
type: EDIT_TAG,
payload: { oldName, newName, color },
});
});
it('throws on error', async () => {

View File

@@ -60,7 +60,13 @@ describe('tagsListReducer', () => {
const newName = 'renamed';
const expectedTags = ['foo', 'renamed', 'baz'].sort();
expect(reducer(state({ tags, filteredTags: tags }), { type: TAG_EDITED, oldName, newName } as any)).toEqual({
expect(reducer(
state({ tags, filteredTags: tags }),
{
type: TAG_EDITED,
payload: { oldName, newName },
} as any,
)).toEqual({
tags: expectedTags,
filteredTags: expectedTags,
});