summaryrefslogtreecommitdiff
path: root/spec/frontend/transfer_edit_spec.js
blob: ad8c9c68f370155fe7a455114466296623a88a83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import $ from 'jquery';

import { loadHTMLFixture } from 'helpers/fixtures';
import setupTransferEdit from '~/transfer_edit';

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);
  });
});