diff options
author | Jan Beckmann <king-jan1999@hotmail.de> | 2019-09-11 17:28:34 +0300 |
---|---|---|
committer | Clement Ho <408677-ClemMakesApps@users.noreply.gitlab.com> | 2019-09-11 17:28:34 +0300 |
commit | c27f619c2a7609af3a7478ae6a6e2d1f210b5be3 (patch) | |
tree | 94e426b17e66de2bfbccba59c95ec9a6d7e1f87b /spec/frontend | |
parent | 0813d1543114883e8ec84cecb5495a3cd9c1f332 (diff) |
Disable "transfer group" button when no parent group is selected
Refactor project_edit.js to be reusable for this purpose
Closes #64799
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/transfer_edit_spec.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/frontend/transfer_edit_spec.js b/spec/frontend/transfer_edit_spec.js new file mode 100644 index 00000000000..3a1ede49068 --- /dev/null +++ b/spec/frontend/transfer_edit_spec.js @@ -0,0 +1,53 @@ +import $ from 'jquery'; + +import setupTransferEdit from '~/transfer_edit'; +import { loadHTMLFixture } from 'helpers/fixtures'; + +describe('setupTransferEdit', () => { + const formSelector = '.js-project-transfer-form'; + const targetSelector = 'select.select2'; + + beforeEach(() => { + loadHTMLFixture('projects/edit.html'); + setupTransferEdit(formSelector, targetSelector); + }); + + it('disables submit button on load', () => { + expect( + $(formSelector) + .find(':submit') + .prop('disabled'), + ).toBe(true); + }); + + it('enables submit button when selection changes to non-empty value', () => { + const nonEmptyValue = $(formSelector) + .find(targetSelector) + .find('option') + .not(':empty') + .val(); + $(formSelector) + .find(targetSelector) + .val(nonEmptyValue) + .trigger('change'); + + expect( + $(formSelector) + .find(':submit') + .prop('disabled'), + ).toBeFalsy(); + }); + + it('disables submit button when selection changes to empty value', () => { + $(formSelector) + .find(targetSelector) + .val('') + .trigger('change'); + + expect( + $(formSelector) + .find(':submit') + .prop('disabled'), + ).toBe(true); + }); +}); |