88ce491fc9
Most browsers do not fire the "input" event for checkboxes or radios. Adds a "change" listener to properly trigger these DirtySubmit updates.
29 lines
975 B
JavaScript
29 lines
975 B
JavaScript
import DirtySubmitCollection from '~/dirty_submit/dirty_submit_collection';
|
|
import { setInputValue, createForm } from './helper';
|
|
|
|
describe('DirtySubmitCollection', () => {
|
|
it('disables submits until there are changes', done => {
|
|
const testElementsCollection = [createForm(), createForm()];
|
|
const forms = testElementsCollection.map(testElements => testElements.form);
|
|
|
|
new DirtySubmitCollection(forms); // eslint-disable-line no-new
|
|
|
|
testElementsCollection.forEach(testElements => {
|
|
const { input, submit } = testElements;
|
|
const originalValue = input.value;
|
|
|
|
expect(submit.disabled).toBe(true);
|
|
|
|
return setInputValue(input, `${originalValue} changes`)
|
|
.then(() => {
|
|
expect(submit.disabled).toBe(false);
|
|
})
|
|
.then(() => setInputValue(input, originalValue))
|
|
.then(() => {
|
|
expect(submit.disabled).toBe(true);
|
|
})
|
|
.then(done)
|
|
.catch(done.fail);
|
|
});
|
|
});
|
|
});
|