Ensured state is reset on edit meta modal after closing it

This commit is contained in:
Alejandro Celaya
2020-01-19 20:37:12 +01:00
parent caa6f7bcd8
commit f52bcc5389
5 changed files with 33 additions and 12 deletions

View File

@@ -35,10 +35,7 @@ describe('<EditTagsModal />', () => {
afterEach(() => {
wrapper && wrapper.unmount();
editShortUrlTags.mockClear();
shortUrlTagsEdited.mockReset();
resetShortUrlsTags.mockReset();
toggle.mockReset();
jest.clearAllMocks();
});
it('resets tags when component is mounted', () => {

View File

@@ -3,7 +3,9 @@ import reducer, {
EDIT_SHORT_URL_META_START,
EDIT_SHORT_URL_META_ERROR,
SHORT_URL_META_EDITED,
RESET_EDIT_SHORT_URL_META,
editShortUrlMeta,
resetShortUrlMeta,
} from '../../../src/short-urls/reducers/shortUrlMeta';
describe('shortUrlMetaReducer', () => {
@@ -36,6 +38,15 @@ describe('shortUrlMetaReducer', () => {
error: false,
});
});
it('goes back to initial state on RESET_EDIT_SHORT_URL_META', () => {
expect(reducer({}, { type: RESET_EDIT_SHORT_URL_META })).toEqual({
meta: {},
shortCode: null,
saving: false,
error: false,
});
});
});
describe('editShortUrlMeta', () => {
@@ -75,4 +86,8 @@ describe('shortUrlMetaReducer', () => {
expect(dispatch).toHaveBeenNthCalledWith(2, { type: EDIT_SHORT_URL_META_ERROR });
});
});
describe('resetShortUrlMeta', () => {
it('creates expected action', () => expect(resetShortUrlMeta()).toEqual({ type: RESET_EDIT_SHORT_URL_META }));
});
});