diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/frontend/dropzone_input_spec.js | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/frontend/dropzone_input_spec.js')
-rw-r--r-- | spec/frontend/dropzone_input_spec.js | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/spec/frontend/dropzone_input_spec.js b/spec/frontend/dropzone_input_spec.js index ba4d838e44b..bde84d3b603 100644 --- a/spec/frontend/dropzone_input_spec.js +++ b/spec/frontend/dropzone_input_spec.js @@ -21,6 +21,10 @@ const TEMPLATE = `<form class="gfm-form" data-uploads-path="${TEST_UPLOAD_PATH}" </form>`; describe('dropzone_input', () => { + afterEach(() => { + resetHTMLFixture(); + }); + it('returns null when failed to initialize', () => { const dropzone = dropzoneInput($('<form class="gfm-form"></form>')); @@ -58,8 +62,6 @@ describe('dropzone_input', () => { afterEach(() => { form = null; - - resetHTMLFixture(); }); it('pastes Markdown tables', () => { @@ -154,8 +156,6 @@ describe('dropzone_input', () => { mock.teardown(); }); - beforeEach(() => {}); - it.each` responseType | responseBody ${'application/json'} | ${JSON.stringify({ message: TEST_ERROR_MESSAGE })} @@ -174,4 +174,36 @@ describe('dropzone_input', () => { }); }); }); + + describe('clickable element', () => { + let form; + + beforeEach(() => { + jest.spyOn($.fn, 'dropzone'); + setHTMLFixture(TEMPLATE); + form = $('form'); + }); + + describe('if attach file button exists', () => { + let attachFileButton; + + beforeEach(() => { + attachFileButton = document.createElement('button'); + attachFileButton.dataset.buttonType = 'attach-file'; + document.body.querySelector('form').appendChild(attachFileButton); + }); + + it('passes attach file button as `clickable` to dropzone', () => { + dropzoneInput(form); + expect($.fn.dropzone.mock.calls[0][0]).toMatchObject({ clickable: attachFileButton }); + }); + }); + + describe('if attach file button does not exist', () => { + it('passes attach file button as `clickable`, if it exists', () => { + dropzoneInput(form); + expect($.fn.dropzone.mock.calls[0][0]).toMatchObject({ clickable: true }); + }); + }); + }); }); |