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

error_spec.js « output « cells « notebook « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2e4ca8c17615596aa9b7e925059348942b486b9f (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
38
39
40
41
42
43
44
45
46
47
48
import { mount } from '@vue/test-utils';
import ErrorOutput from '~/notebook/cells/output/error.vue';
import Prompt from '~/notebook/cells/prompt.vue';
import Markdown from '~/notebook/cells/markdown.vue';
import { errorOutputContent, relativeRawPath } from '../../mock_data';

describe('notebook/cells/output/error.vue', () => {
  let wrapper;

  const createComponent = () => {
    wrapper = mount(ErrorOutput, {
      propsData: {
        rawCode: errorOutputContent,
        index: 1,
        count: 2,
      },
      provide: { relativeRawPath },
    });
  };

  beforeEach(() => {
    createComponent();
  });

  const findPrompt = () => wrapper.findComponent(Prompt);
  const findMarkdown = () => wrapper.findComponent(Markdown);

  it('renders the prompt', () => {
    expect(findPrompt().props()).toMatchObject({ count: 2, showOutput: true, type: 'Out' });
  });

  it('renders the markdown', () => {
    const expectedParsedMarkdown =
      '```error\n' +
      '---------------------------------------------------------------------------\n' +
      'NameError                                 Traceback (most recent call last)\n' +
      '/var/folders/cq/l637k4x13gx6y9p_gfs4c_gc0000gn/T/ipykernel_79203/294318627.py in <module>\n' +
      '----> 1 To\n' +
      '\n' +
      "NameError: name 'To' is not defined\n" +
      '```';

    expect(findMarkdown().props()).toMatchObject({
      cell: { source: [expectedParsedMarkdown] },
      hidePrompt: true,
    });
  });
});