summaryrefslogtreecommitdiff
path: root/spec/frontend/notebook/cells/output/html_spec.js
blob: 48d62d74a500934c562452c69351bb3fcad842dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import Vue from 'vue';
import htmlOutput from '~/notebook/cells/output/html.vue';
import sanitizeTests from './html_sanitize_fixtures';

describe('html output cell', () => {
  function createComponent(rawCode) {
    const Component = Vue.extend(htmlOutput);

    return new Component({
      propsData: {
        rawCode,
        count: 0,
        index: 0,
      },
    }).$mount();
  }

  it.each(sanitizeTests)('sanitizes output for: %p', (name, { input, output }) => {
    const vm = createComponent(input);
    const outputEl = [...vm.$el.querySelectorAll('div')].pop();

    expect(outputEl.innerHTML).toEqual(output);

    vm.$destroy();
  });
});