diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-13 15:08:49 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-13 15:08:49 +0300 |
commit | 988424215cf104d9ee24bb1751141424cffb32d1 (patch) | |
tree | 9d2525571ecc693902b949ac8441e8c97b299c3c /spec/frontend/pager_spec.js | |
parent | 2705a15deaef07b1a38a53b9539d02f8ad499ce3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/pager_spec.js')
-rw-r--r-- | spec/frontend/pager_spec.js | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/spec/frontend/pager_spec.js b/spec/frontend/pager_spec.js index 9df69124d66..dfb3e87a342 100644 --- a/spec/frontend/pager_spec.js +++ b/spec/frontend/pager_spec.js @@ -1,5 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; import $ from 'jquery'; +import { setHTMLFixture, resetHTMLFixture } from 'helpers/fixtures'; import { TEST_HOST } from 'helpers/test_constants'; import waitForPromises from 'helpers/wait_for_promises'; import axios from '~/lib/utils/axios_utils'; @@ -26,12 +27,14 @@ describe('pager', () => { const originalHref = window.location.href; beforeEach(() => { - setFixtures('<div class="content_list"></div><div class="loading"></div>'); + setHTMLFixture('<div class="content_list"></div><div class="loading"></div>'); jest.spyOn($.fn, 'endlessScroll').mockImplementation(); }); afterEach(() => { window.history.replaceState({}, null, originalHref); + + resetHTMLFixture(); }); it('should get initial offset from query parameter', () => { @@ -57,7 +60,7 @@ describe('pager', () => { } beforeEach(() => { - setFixtures( + setHTMLFixture( '<div class="content_list" data-href="/some_list"></div><div class="loading"></div>', ); jest.spyOn(axios, 'get'); @@ -65,6 +68,10 @@ describe('pager', () => { Pager.init(); }); + afterEach(() => { + resetHTMLFixture(); + }); + it('shows loader while loading next page', async () => { mockSuccess(); @@ -135,7 +142,11 @@ describe('pager', () => { const href = `${TEST_HOST}/some_list.json`; beforeEach(() => { - setFixtures(`<div class="content_list" data-href="${href}"></div>`); + setHTMLFixture(`<div class="content_list" data-href="${href}"></div>`); + }); + + afterEach(() => { + resetHTMLFixture(); }); it('should use data-href attribute', () => { @@ -154,7 +165,11 @@ describe('pager', () => { describe('no data-href attribute attribute provided from list element', () => { beforeEach(() => { - setFixtures(`<div class="content_list"></div>`); + setHTMLFixture(`<div class="content_list"></div>`); + }); + + afterEach(() => { + resetHTMLFixture(); }); it('should use current url', () => { @@ -190,7 +205,7 @@ describe('pager', () => { describe('when `container` is visible', () => { it('makes API request', () => { - setFixtures( + setHTMLFixture( `<div id="js-pager"><div class="content_list" data-href="${href}"></div></div>`, ); @@ -199,12 +214,14 @@ describe('pager', () => { endlessScrollCallback(); expect(axios.get).toHaveBeenCalledWith(href, expect.any(Object)); + + resetHTMLFixture(); }); }); describe('when `container` is not visible', () => { it('does not make API request', () => { - setFixtures( + setHTMLFixture( `<div id="js-pager" style="display: none;"><div class="content_list" data-href="${href}"></div></div>`, ); @@ -213,6 +230,8 @@ describe('pager', () => { endlessScrollCallback(); expect(axios.get).not.toHaveBeenCalled(); + + resetHTMLFixture(); }); }); }); |