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

blockquote_spec.js « extensions « content_editor « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1644647ba6943558d3094f3b26498e01562d93c0 (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
27
28
29
30
31
32
33
34
35
36
37
import Blockquote from '~/content_editor/extensions/blockquote';
import { createTestEditor, createDocBuilder, triggerNodeInputRule } from '../test_utils';

describe('content_editor/extensions/blockquote', () => {
  let tiptapEditor;
  let doc;
  let p;
  let blockquote;

  beforeEach(() => {
    tiptapEditor = createTestEditor({ extensions: [Blockquote] });

    ({
      builders: { doc, p, blockquote },
    } = createDocBuilder({
      tiptapEditor,
      names: {
        blockquote: { nodeType: Blockquote.name },
      },
    }));
  });

  it.each`
    input      | insertedNode
    ${'>>> '}  | ${() => blockquote({ multiline: true }, p())}
    ${'> '}    | ${() => blockquote(p())}
    ${' >>> '} | ${() => blockquote({ multiline: true }, p())}
    ${'>> '}   | ${() => p()}
    ${'>>>x '} | ${() => p()}
  `('with input=$input, then should insert a $insertedNode', ({ input, insertedNode }) => {
    const expectedDoc = doc(insertedNode());

    triggerNodeInputRule({ tiptapEditor, inputRuleText: input });

    expect(tiptapEditor.getJSON()).toEqual(expectedDoc.toJSON());
  });
});