debian-mirror-gitlab/spec/frontend/dirty_submit/dirty_submit_collection_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
851 B
JavaScript
Raw Normal View History

2020-05-24 23:13:21 +05:30
import DirtySubmitCollection from '~/dirty_submit/dirty_submit_collection';
import { setInputValue, createForm } from './helper';
2021-03-08 18:12:59 +05:30
jest.mock('lodash/throttle', () => jest.fn((fn) => fn));
2020-05-24 23:13:21 +05:30
describe('DirtySubmitCollection', () => {
const testElementsCollection = [createForm(), createForm()];
2021-03-08 18:12:59 +05:30
const forms = testElementsCollection.map((testElements) => testElements.form);
2020-05-24 23:13:21 +05:30
new DirtySubmitCollection(forms); // eslint-disable-line no-new
2021-03-08 18:12:59 +05:30
it.each(testElementsCollection)('disables submits until there are changes', (testElements) => {
2020-05-24 23:13:21 +05:30
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);
});
});