debian-mirror-gitlab/spec/frontend/transfer_edit_spec.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

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', () => {
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);
});
});