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

add_user_modal_spec.js « components « user_lists « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 82ce195d7cd35caeed8628f9df8177cf52f019ff (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
49
50
import { mount } from '@vue/test-utils';
import AddUserModal from '~/user_lists/components/add_user_modal.vue';

describe('Add User Modal', () => {
  let wrapper;

  const click = testId => wrapper.find(`[data-testid="${testId}"]`).trigger('click');

  beforeEach(() => {
    wrapper = mount(AddUserModal, {
      propsData: { visible: true },
    });
  });

  it('should explain the format of user IDs to enter', () => {
    expect(wrapper.find('[data-testid="add-userids-description"]').text()).toContain(
      'Enter a comma separated list of user IDs',
    );
  });

  describe('events', () => {
    beforeEach(() => {
      wrapper.find('#add-user-ids').setValue('1, 2, 3, 4');
    });

    it('should emit the users entered when Add Users is clicked', () => {
      click('confirm-add-user-ids');
      expect(wrapper.emitted('addUsers')).toContainEqual(['1, 2, 3, 4']);
    });

    it('should clear the input after emitting', async () => {
      click('confirm-add-user-ids');
      await wrapper.vm.$nextTick();

      expect(wrapper.find('#add-user-ids').element.value).toBe('');
    });

    it('should not emit the users entered if cancel is clicked', () => {
      click('cancel-add-user-ids');
      expect(wrapper.emitted('addUsers')).toBeUndefined();
    });

    it('should clear the input after cancelling', async () => {
      click('cancel-add-user-ids');
      await wrapper.vm.$nextTick();

      expect(wrapper.find('#add-user-ids').element.value).toBe('');
    });
  });
});