summaryrefslogtreecommitdiff
path: root/spec/frontend/notes/components/discussion_reply_placeholder_spec.js
blob: 3932f818c4ef4c4f778cbc44e112d82b626dd530 (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
import { shallowMount } from '@vue/test-utils';
import ReplyPlaceholder from '~/notes/components/discussion_reply_placeholder.vue';

const placeholderText = 'Test Button Text';

describe('ReplyPlaceholder', () => {
  let wrapper;

  const createComponent = ({ options = {} } = {}) => {
    wrapper = shallowMount(ReplyPlaceholder, {
      propsData: {
        placeholderText,
      },
      ...options,
    });
  };

  const findTextarea = () => wrapper.find({ ref: 'textarea' });

  afterEach(() => {
    wrapper.destroy();
  });

  it('emits focus event on button click', async () => {
    createComponent({ options: { attachTo: document.body } });

    await findTextarea().trigger('focus');

    expect(wrapper.emitted()).toEqual({
      focus: [[]],
    });
  });

  it('should render reply button', () => {
    createComponent();

    expect(findTextarea().attributes('placeholder')).toEqual(placeholderText);
  });
});