Skip to content
Snippets Groups Projects
Unverified Commit 951521f3 authored by Paul Slaughter's avatar Paul Slaughter
Browse files

Use standard mock IntersectionObserver in specs

Also updates snapshots which are capturing default
prop.
parent 6e2dbaab
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -9,17 +9,15 @@ import { initialRequest } from 'jest/issue_show/mock_data';
import { TEST_HOST } from 'spec/test_constants';
import axios from '~/lib/utils/axios_utils';
import { mockEpicMeta, mockEpicData } from '../mock_data';
import { useMockIntersectionObserver } from 'helpers/mock_dom_observer';
 
describe('EpicAppComponent', () => {
useMockIntersectionObserver();
let vm;
let mock;
 
beforeEach(() => {
window.IntersectionObserver = class {
disconnect = jest.fn();
observe = jest.fn();
};
mock = new MockAdapter(axios);
mock.onGet(`${TEST_HOST}/realtime_changes`).reply(200, initialRequest);
 
Loading
Loading
@@ -34,7 +32,6 @@ describe('EpicAppComponent', () => {
});
 
afterEach(() => {
delete window.IntersectionObserver;
mock.restore();
vm.$destroy();
});
Loading
Loading
Loading
Loading
@@ -9,17 +9,15 @@ import { initialRequest } from 'jest/issue_show/mock_data';
import { TEST_HOST } from 'spec/test_constants';
import axios from '~/lib/utils/axios_utils';
import { mockEpicMeta, mockEpicData } from '../mock_data';
import { useMockIntersectionObserver } from 'helpers/mock_dom_observer';
 
describe('EpicBodyComponent', () => {
useMockIntersectionObserver();
let vm;
let mock;
 
beforeEach(() => {
window.IntersectionObserver = class {
disconnect = jest.fn();
observe = jest.fn();
};
mock = new MockAdapter(axios);
mock.onGet(`${TEST_HOST}/realtime_changes`).reply(200, initialRequest);
 
Loading
Loading
@@ -34,7 +32,6 @@ describe('EpicBodyComponent', () => {
});
 
afterEach(() => {
delete window.IntersectionObserver;
mock.restore();
vm.$destroy();
});
Loading
Loading
Loading
Loading
@@ -31,9 +31,7 @@ exports[`Design management list item component with no notes renders item with c
</span>
</div>
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -99,9 +97,7 @@ exports[`Design management list item component with no notes renders item with c
</span>
</div>
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -167,9 +163,7 @@ exports[`Design management list item component with no notes renders item with c
</span>
</div>
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -222,9 +216,7 @@ exports[`Design management list item component with no notes renders item with n
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -277,9 +269,7 @@ exports[`Design management list item component with no notes renders loading spi
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<gl-loading-icon-stub
color="orange"
label="Loading"
Loading
Loading
@@ -337,9 +327,7 @@ exports[`Design management list item component with notes renders item with mult
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -409,9 +397,7 @@ exports[`Design management list item component with notes renders item with sing
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
Loading
Loading
@@ -31,9 +31,7 @@ exports[`Design management list item component with no notes renders item with c
</span>
</div>
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -99,9 +97,7 @@ exports[`Design management list item component with no notes renders item with c
</span>
</div>
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -167,9 +163,7 @@ exports[`Design management list item component with no notes renders item with c
</span>
</div>
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -222,9 +216,7 @@ exports[`Design management list item component with no notes renders item with n
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -277,9 +269,7 @@ exports[`Design management list item component with no notes renders loading spi
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<gl-loading-icon-stub
color="orange"
label="Loading"
Loading
Loading
@@ -337,9 +327,7 @@ exports[`Design management list item component with notes renders item with mult
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
@@ -409,9 +397,7 @@ exports[`Design management list item component with notes renders item with sing
>
<!---->
<gl-intersection-observer-stub
options="[object Object]"
>
<gl-intersection-observer-stub>
<!---->
<img
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@ import '~/behaviors/markdown/render_gfm';
import IssuableApp from '~/issue_show/components/app.vue';
import eventHub from '~/issue_show/event_hub';
import { initialRequest, secondRequest } from '../mock_data';
import { useMockIntersectionObserver } from 'helpers/mock_dom_observer';
 
function formatText(text) {
return text.trim().replace(/\s\s+/g, ' ');
Loading
Loading
@@ -22,6 +23,8 @@ const zoomMeetingUrl = 'https://gitlab.zoom.us/j/95919234811';
const publishedIncidentUrl = 'https://status.com/';
 
describe('Issuable output', () => {
useMockIntersectionObserver();
let mock;
let realtimeRequestCount = 0;
let wrapper;
Loading
Loading
@@ -45,11 +48,6 @@ describe('Issuable output', () => {
</div>
`);
 
window.IntersectionObserver = class {
disconnect = jest.fn();
observe = jest.fn();
};
mock = new MockAdapter(axios);
mock
.onGet('/gitlab-org/gitlab-shell/-/issues/9/realtime_changes/realtime_changes')
Loading
Loading
@@ -84,7 +82,6 @@ describe('Issuable output', () => {
});
 
afterEach(() => {
delete window.IntersectionObserver;
mock.restore();
realtimeRequestCount = 0;
 
Loading
Loading
import autofocusonshow from '~/vue_shared/directives/autofocusonshow';
import { useMockIntersectionObserver } from 'helpers/mock_dom_observer';
 
/**
* We're testing this directive's hooks as pure functions
Loading
Loading
@@ -6,20 +7,14 @@ import autofocusonshow from '~/vue_shared/directives/autofocusonshow';
* on underlying DOM methods.
*/
describe('AutofocusOnShow directive', () => {
useMockIntersectionObserver();
describe('with input invisible on component render', () => {
let el;
 
beforeEach(() => {
setFixtures('<div id="container" style="display: none;"><input id="inputel"/></div>');
el = document.querySelector('#inputel');
window.IntersectionObserver = class {
observe = jest.fn();
};
});
afterEach(() => {
delete window.IntersectionObserver;
});
 
it('should bind IntersectionObserver on input element', () => {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment