diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-08-20 12:30:26 +0200 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-08-20 12:30:26 +0200 |
commit | c381ea88506ad69d677322e00a674dc5cf216559 (patch) | |
tree | 63a1962638a22e0ade13b7b6e4d01988a321c5d9 | |
parent | 51c19691e4c4ceb60ef28fd08c6b13549a423a39 (diff) | |
download | gitlab-ce-winh-autosave_spec-sync.tar.gz |
Make native event test in autosave_spec.js synchronouswinh-autosave_spec-sync
-rw-r--r-- | spec/frontend/autosave_spec.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/spec/frontend/autosave_spec.js b/spec/frontend/autosave_spec.js index 4d9c8f96d62..33d402388c9 100644 --- a/spec/frontend/autosave_spec.js +++ b/spec/frontend/autosave_spec.js @@ -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); }); }); |