Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/behaviors/autosize_spec.js')
-rw-r--r--spec/frontend/behaviors/autosize_spec.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/spec/frontend/behaviors/autosize_spec.js b/spec/frontend/behaviors/autosize_spec.js
index a9dbee7fd08..7008b7b2eb6 100644
--- a/spec/frontend/behaviors/autosize_spec.js
+++ b/spec/frontend/behaviors/autosize_spec.js
@@ -1,4 +1,5 @@
import '~/behaviors/autosize';
+import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures';
jest.mock('~/helpers/startup_css_helper', () => {
return {
@@ -20,19 +21,22 @@ jest.mock('~/helpers/startup_css_helper', () => {
describe('Autosize behavior', () => {
beforeEach(() => {
- setFixtures('<textarea class="js-autosize"></textarea>');
+ setHTMLFixture('<textarea class="js-autosize"></textarea>');
+ });
+
+ afterEach(() => {
+ resetHTMLFixture();
});
it('is applied to the textarea', () => {
// This is the second part of the Hack:
// Because we are forcing the mock for WaitForCSSLoaded and the very end of our callstack
// to call its callback. This querySelector needs to go to the very end of our callstack
- // as well, if we would not have this setTimeout Function here, the querySelector
- // would run before the mockImplementation called its callBack Function
- // the DOM Manipulation didn't happen yet and the test would fail.
- setTimeout(() => {
- const textarea = document.querySelector('textarea');
- expect(textarea.classList).toContain('js-autosize-initialized');
- }, 0);
+ // as well, if we would not have this jest.runOnlyPendingTimers here, the querySelector
+ // would not run and the test would fail.
+ jest.runOnlyPendingTimers();
+
+ const textarea = document.querySelector('textarea');
+ expect(textarea.classList).toContain('js-autosize-initialized');
});
});