Welcome to mirror list, hosted at ThFree Co, Russian Federation.

wrap_child_nodes_spec.js « plugins « source_viewer « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45fef09aa845677e9ee30d5e5fcd601a28477727 (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
import wrapChildNodes from '~/vue_shared/components/source_viewer/plugins/wrap_child_nodes';

describe('Highlight.js plugin for wrapping _emitter nodes', () => {
  it('mutates the input value by wrapping each node in a span tag', () => {
    const hljsResultMock = {
      _emitter: {
        rootNode: {
          children: [
            { scope: 'string', children: ['Text 1'] },
            { scope: 'string', children: ['Text 2', { scope: 'comment', children: ['Text 3'] }] },
            { scope: undefined, sublanguage: true, children: ['Text 4 (sublanguage)'] },
            { scope: undefined, sublanguage: undefined, children: ['Text 5'] },
            'Text6\nText7',
          ],
        },
      },
    };

    const outputValue = `<span class="hljs-string">Text 1</span><span class="hljs-string"><span class="hljs-string">Text 2</span><span class="hljs-comment">Text 3</span></span><span class="">Text 4 (sublanguage)</span><span class="">Text 5</span><span class="">Text6</span>\n<span class="">Text7</span>`;

    wrapChildNodes(hljsResultMock);
    expect(hljsResultMock.value).toBe(outputValue);
  });
});