Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dirty_submit_collection_spec.js « dirty_submit « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 465391633e6dd4a9b76be00a5aa4db91ef5e9d25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import DirtySubmitCollection from '~/dirty_submit/dirty_submit_collection';
import { setInputValue, createForm } from './helper';

jest.mock('lodash/throttle', () => jest.fn((fn) => fn));

describe('DirtySubmitCollection', () => {
  const testElementsCollection = [createForm(), createForm()];
  const forms = testElementsCollection.map((testElements) => testElements.form);

  new DirtySubmitCollection(forms); // eslint-disable-line no-new

  it.each(testElementsCollection)('disables submits until there are changes', (testElements) => {
    const { input, submit } = testElements;
    const originalValue = input.value;

    expect(submit.disabled).toBe(true);
    setInputValue(input, `${originalValue} changes`);
    expect(submit.disabled).toBe(false);
    setInputValue(input, originalValue);
    expect(submit.disabled).toBe(true);
  });
});