summaryrefslogtreecommitdiff
path: root/spec/frontend/work_items/components/notes/work_item_note_body_spec.js
blob: 4fcbcfcaf307d1b1f2822e72769586b7a1ae48eb (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
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import WorkItemNoteBody from '~/work_items/components/notes/work_item_note_body.vue';
import NoteEditedText from '~/notes/components/note_edited_text.vue';
import { mockWorkItemCommentNote } from 'jest/work_items/mock_data';

describe('Work Item Note Body', () => {
  let wrapper;

  const findNoteBody = () => wrapper.findByTestId('work-item-note-body');
  const findNoteEditedText = () => wrapper.findComponent(NoteEditedText);

  const createComponent = ({ note = mockWorkItemCommentNote } = {}) => {
    wrapper = shallowMountExtended(WorkItemNoteBody, {
      propsData: {
        note,
      },
    });
  };

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

  it('should have the wrapper to show the note body', () => {
    expect(findNoteBody().exists()).toBe(true);
    expect(findNoteBody().html()).toMatchSnapshot();
  });

  it('should not show the edited text when the value is not present', () => {
    expect(findNoteEditedText().exists()).toBe(false);
  });
});