diff options
Diffstat (limited to 'spec/frontend/captcha')
-rw-r--r-- | spec/frontend/captcha/init_recaptcha_script_spec.js | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/spec/frontend/captcha/init_recaptcha_script_spec.js b/spec/frontend/captcha/init_recaptcha_script_spec.js index 77f78d36991..df114821651 100644 --- a/spec/frontend/captcha/init_recaptcha_script_spec.js +++ b/spec/frontend/captcha/init_recaptcha_script_spec.js @@ -7,19 +7,11 @@ import { describe('initRecaptchaScript', () => { afterEach(() => { - // NOTE: The DOM is guaranteed to be clean at the start of a new test file, but it isn't cleaned - // between examples within a file, so we need to clean it after each one. See more context here: - // - https://github.com/facebook/jest/issues/1224 - // - https://stackoverflow.com/questions/42805128/does-jest-reset-the-jsdom-document-after-every-suite-or-test - // - // Also note as mentioned in https://github.com/facebook/jest/issues/1224#issuecomment-444586798 - // that properties of `window` are NOT cleared between test files. So, we are also - // explicitly unsetting it. document.head.innerHTML = ''; - window[RECAPTCHA_ONLOAD_CALLBACK_NAME] = undefined; clearMemoizeCache(); }); + const getScriptOnload = () => window[RECAPTCHA_ONLOAD_CALLBACK_NAME]; const triggerScriptOnload = (...args) => window[RECAPTCHA_ONLOAD_CALLBACK_NAME](...args); describe('when called', () => { @@ -51,6 +43,7 @@ describe('initRecaptchaScript', () => { triggerScriptOnload(instance); await expect(result).resolves.toBe(instance); + expect(getScriptOnload()).toBeUndefined(); }); }); }); |