Make native event test in autosave_spec.js synchronous

This commit is contained in:
Winnie Hellmann 2019-08-21 08:01:58 +00:00 committed by Kushal Pandya
parent 3ac4a2989d
commit 208cc38d98

View file

@ -63,12 +63,15 @@ describe('Autosave', () => {
expect(field.trigger).toHaveBeenCalled();
});
it('triggers native event', done => {
autosave.field.get(0).addEventListener('change', () => {
done();
});
it('triggers native event', () => {
const fieldElement = autosave.field.get(0);
const eventHandler = jest.fn();
fieldElement.addEventListener('change', eventHandler);
Autosave.prototype.restore.call(autosave);
expect(eventHandler).toHaveBeenCalledTimes(1);
fieldElement.removeEventListener('change', eventHandler);
});
});