diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-07 21:07:59 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-07 21:07:59 +0300 |
commit | 3ff3d897d6529aabb21aa6aed54eb430a9cf0fe2 (patch) | |
tree | d5aaf0b6766cd5d4118e8ccd57d1269d3e4d673e /spec/frontend/zen_mode_spec.js | |
parent | 807c4eae46f96ccd54ce1d8d13f4547eda017267 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/zen_mode_spec.js')
-rw-r--r-- | spec/frontend/zen_mode_spec.js | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/spec/frontend/zen_mode_spec.js b/spec/frontend/zen_mode_spec.js index 85f1dbdc305..025a92464f1 100644 --- a/spec/frontend/zen_mode_spec.js +++ b/spec/frontend/zen_mode_spec.js @@ -15,6 +15,8 @@ describe('ZenMode', () => { let dropzoneForElementSpy; const fixtureName = 'snippets/show.html'; + const getTextarea = () => $('.notes-form textarea'); + function enterZen() { $('.notes-form .js-zen-enter').click(); } @@ -24,7 +26,7 @@ describe('ZenMode', () => { } function escapeKeydown() { - $('.notes-form textarea').trigger( + getTextarea().trigger( $.Event('keydown', { keyCode: 27, }), @@ -50,6 +52,12 @@ describe('ZenMode', () => { }); afterEach(() => { + $(document).off('click', '.js-zen-enter'); + $(document).off('click', '.js-zen-leave'); + $(document).off('zen_mode:enter'); + $(document).off('zen_mode:leave'); + $(document).off('keydown'); + resetHTMLFixture(); }); @@ -62,14 +70,14 @@ describe('ZenMode', () => { $('.div-dropzone').addClass('js-invalid-dropzone'); exitZen(); - expect(dropzoneForElementSpy.mock.calls.length).toEqual(0); + expect(dropzoneForElementSpy).not.toHaveBeenCalled(); }); it('should call dropzone if element is dropzone valid', () => { $('.div-dropzone').removeClass('js-invalid-dropzone'); exitZen(); - expect(dropzoneForElementSpy.mock.calls.length).toEqual(2); + expect(dropzoneForElementSpy).toHaveBeenCalledTimes(1); }); }); @@ -82,10 +90,10 @@ describe('ZenMode', () => { }); it('removes textarea styling', () => { - $('.notes-form textarea').attr('style', 'height: 400px'); + getTextarea().attr('style', 'height: 400px'); enterZen(); - expect($('.notes-form textarea')).not.toHaveAttr('style'); + expect(getTextarea()).not.toHaveAttr('style'); }); }); @@ -116,4 +124,15 @@ describe('ZenMode', () => { expect(utils.scrollToElement).toHaveBeenCalled(); }); }); + + it('restores textarea style', () => { + const style = 'color: red; overflow-y: hidden;'; + getTextarea().attr('style', style); + expect(getTextarea()).toHaveAttr('style', style); + + enterZen(); + exitZen(); + + expect(getTextarea()).toHaveAttr('style', style); + }); }); |