debian-mirror-gitlab/spec/frontend/behaviors/markdown/render_metrics_spec.js
2019-10-12 21:52:04 +05:30

37 lines
870 B
JavaScript

import Vue from 'vue';
import renderMetrics from '~/behaviors/markdown/render_metrics';
import { TEST_HOST } from 'helpers/test_constants';
const originalExtend = Vue.extend;
describe('Render metrics for Gitlab Flavoured Markdown', () => {
const container = {
Metrics() {},
};
let spyExtend;
beforeEach(() => {
Vue.extend = () => container.Metrics;
spyExtend = jest.spyOn(Vue, 'extend');
});
afterEach(() => {
Vue.extend = originalExtend;
});
it('does nothing when no elements are found', () => {
renderMetrics([]);
expect(spyExtend).not.toHaveBeenCalled();
});
it('renders a vue component when elements are found', () => {
const element = document.createElement('div');
element.setAttribute('data-dashboard-url', TEST_HOST);
renderMetrics([element]);
expect(spyExtend).toHaveBeenCalled();
});
});