debian-mirror-gitlab/spec/frontend/behaviors/markdown/render_observability_spec.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

44 lines
1.4 KiB
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import Vue from 'vue';
import { createWrapper } from '@vue/test-utils';
2023-03-04 22:38:38 +05:30
import renderObservability from '~/behaviors/markdown/render_observability';
2023-05-27 22:25:52 +05:30
import { INLINE_EMBED_DIMENSIONS, SKELETON_VARIANT_EMBED } from '~/observability/constants';
import ObservabilityApp from '~/observability/components/observability_app.vue';
2023-03-04 22:38:38 +05:30
2023-05-27 22:25:52 +05:30
describe('renderObservability', () => {
let subject;
2023-03-04 22:38:38 +05:30
beforeEach(() => {
2023-05-27 22:25:52 +05:30
subject = document.createElement('div');
subject.classList.add('js-render-observability');
subject.dataset.frameUrl = 'https://observe.gitlab.com/';
document.body.appendChild(subject);
2023-03-04 22:38:38 +05:30
});
2023-05-27 22:25:52 +05:30
afterEach(() => {
subject.remove();
2023-03-04 22:38:38 +05:30
});
2023-05-27 22:25:52 +05:30
it('should return an array of Vue instances', () => {
const vueInstances = renderObservability([
...document.querySelectorAll('.js-render-observability'),
]);
expect(vueInstances).toEqual([expect.any(Vue)]);
2023-03-04 22:38:38 +05:30
});
2023-05-08 21:46:49 +05:30
2023-05-27 22:25:52 +05:30
it('should correctly pass props to the ObservabilityApp component', () => {
const vueInstances = renderObservability([
...document.querySelectorAll('.js-render-observability'),
]);
2023-05-08 21:46:49 +05:30
2023-05-27 22:25:52 +05:30
const wrapper = createWrapper(vueInstances[0]);
2023-05-08 21:46:49 +05:30
2023-05-27 22:25:52 +05:30
expect(wrapper.findComponent(ObservabilityApp).props()).toMatchObject({
observabilityIframeSrc: 'https://observe.gitlab.com/',
skeletonVariant: SKELETON_VARIANT_EMBED,
inlineEmbed: true,
height: INLINE_EMBED_DIMENSIONS.HEIGHT,
width: INLINE_EMBED_DIMENSIONS.WIDTH,
});
2023-05-08 21:46:49 +05:30
});
2023-03-04 22:38:38 +05:30
});