2019-12-04 20:38:33 +05:30
|
|
|
import $ from 'jquery';
|
|
|
|
|
|
|
|
import { loadHTMLFixture } from 'helpers/fixtures';
|
2020-01-01 13:55:28 +05:30
|
|
|
import setupTransferEdit from '~/transfer_edit';
|
2019-12-04 20:38:33 +05:30
|
|
|
|
|
|
|
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', () => {
|
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', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
const nonEmptyValue = $(formSelector).find(targetSelector).find('option').not(':empty').val();
|
|
|
|
$(formSelector).find(targetSelector).val(nonEmptyValue).trigger('change');
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|