Skip to content

Commit

Permalink
test: adding test for insertlinkmodaltoggle hook
Browse files Browse the repository at this point in the history
  • Loading branch information
johnvente committed Jan 18, 2024
1 parent e9dee15 commit 6125a8d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/editors/sharedComponents/TinyMceWidget/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('TinyMceEditor hooks', () => {
state.testGetter(state.keys.isImageModalOpen);
state.testGetter(state.keys.isSourceCodeModalOpen);
state.testGetter(state.keys.imageSelection);
state.testGetter(state.keys.isInsertLinkModalOpen);
});

describe('non-state hooks', () => {
Expand Down Expand Up @@ -404,6 +405,24 @@ describe('TinyMceEditor hooks', () => {
});
});

describe('insertLinkModalToggle', () => {
const hookKey = state.keys.isInsertLinkModalOpen;
beforeEach(() => {
hook = module.insertLinkModalToggle();
});
test('isInsertLinkOpen: state value', () => {
expect(hook.isInsertLinkOpen).toEqual(state.stateVals[hookKey]);
});
test('openInsertLinkModal: calls setter with true', () => {
hook.openInsertLinkModal();
expect(state.setState[hookKey]).toHaveBeenCalledWith(true);
});
test('closeInsertLinkModal: calls setter with false', () => {
hook.closeInsertLinkModal();
expect(state.setState[hookKey]).toHaveBeenCalledWith(false);
});
});

describe('openModalWithSelectedImage', () => {
const setImage = jest.fn();
const openImgModal = jest.fn();
Expand Down

0 comments on commit 6125a8d

Please sign in to comment.