Add helper for mocking/stubbing form.submit

JSDOM doesn't implement the submit method on form
elements. It does have a submit method but this
just fires a 'not implemented' error.

We need to spy on form submissions fired by
clicking on the submit button but can't because
this event calls the submit method internally so
spying on `form.submit` doesn't work.

This adds a helper which spies on the internal
method that is actually called. When JSDOM
implements the submit method properly this should
be removed.
This commit is contained in:
Tom Byers
2019-09-04 10:24:31 +01:00
parent 73587798ab
commit 3c1576dacf
2 changed files with 35 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ const domInterfaces = require('./helpers/dom_interfaces.js');
const html = require('./helpers/html.js');
const elements = require('./helpers/elements.js');
const rendering = require('./helpers/rendering.js');
const forms = require('./helpers/forms.js');
exports.triggerEvent = events.triggerEvent;
exports.clickElementWithMouse = events.clickElementWithMouse;
@@ -15,3 +16,4 @@ exports.getRadios = html.getRadios;
exports.element = elements.element;
exports.WindowMock = rendering.WindowMock;
exports.ScreenMock = rendering.ScreenMock;
exports.spyOnFormSubmit = forms.spyOnFormSubmit;