2019-12-04 20:38:33 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
|
|
|
|
import { loadHTMLFixture } from 'helpers/fixtures';
|
2022-03-02 08:16:31 +05:30
|
|
|
import setupTransferEdit from '~/groups/transfer_edit';
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
describe('setupTransferEdit', () => {
|
2022-01-26 12:08:38 +05:30
|
|
|
const formSelector = '.js-group-transfer-form';
|
|
|
|
const targetSelector = '#new_parent_group_id';
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-01-26 12:08:38 +05:30
|
|
|
loadHTMLFixture('groups/edit.html');
|
2019-12-04 20:38:33 +05:30
|
|
|
setupTransferEdit(formSelector, targetSelector);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('disables submit button on load', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
expect($(formSelector).find(':submit').prop('disabled')).toBe(true);
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('enables submit button when selection changes to non-empty value', () => {
|
2022-01-26 12:08:38 +05:30
|
|
|
const lastValue = $(formSelector).find(targetSelector).find('.dropdown-content li').last();
|
|
|
|
$(formSelector).find(targetSelector).val(lastValue).trigger('change');
|
2021-03-08 18:12:59 +05:30
|
|
|
|
|
|
|
expect($(formSelector).find(':submit').prop('disabled')).toBeFalsy();
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('disables submit button when selection changes to empty value', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
$(formSelector).find(targetSelector).val('').trigger('change');
|
|
|
|
|
|
|
|
expect($(formSelector).find(':submit').prop('disabled')).toBe(true);
|
2019-12-04 20:38:33 +05:30
|
|
|
});
|
|
|
|
});
|