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

user_avatar_image_spec.js « user_avatar « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 75d2a936b347b9872bca70851bce342f96565ab2 (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
51
52
53
54
55
56
57
58
59
60
61
import { shallowMount } from '@vue/test-utils';
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
import UserAvatarImageNew from '~/vue_shared/components/user_avatar/user_avatar_image_new.vue';
import UserAvatarImageOld from '~/vue_shared/components/user_avatar/user_avatar_image_old.vue';

const PROVIDED_PROPS = {
  size: 32,
  imgSrc: 'myavatarurl.com',
  imgAlt: 'mydisplayname',
  cssClasses: 'myextraavatarclass',
  tooltipText: 'tooltip text',
  tooltipPlacement: 'bottom',
};

describe('User Avatar Image Component', () => {
  let wrapper;

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

  describe('when `glAvatarForAllUserAvatars` feature flag enabled', () => {
    beforeEach(() => {
      wrapper = shallowMount(UserAvatarImage, {
        propsData: {
          ...PROVIDED_PROPS,
        },
        provide: {
          glFeatures: {
            glAvatarForAllUserAvatars: true,
          },
        },
      });
    });

    it('should render `UserAvatarImageNew` component', () => {
      expect(wrapper.findComponent(UserAvatarImageNew).exists()).toBe(true);
      expect(wrapper.findComponent(UserAvatarImageOld).exists()).toBe(false);
    });
  });

  describe('when `glAvatarForAllUserAvatars` feature flag disabled', () => {
    beforeEach(() => {
      wrapper = shallowMount(UserAvatarImage, {
        propsData: {
          ...PROVIDED_PROPS,
        },
        provide: {
          glFeatures: {
            glAvatarForAllUserAvatars: false,
          },
        },
      });
    });

    it('should render `UserAvatarImageOld` component', () => {
      expect(wrapper.findComponent(UserAvatarImageNew).exists()).toBe(false);
      expect(wrapper.findComponent(UserAvatarImageOld).exists()).toBe(true);
    });
  });
});