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: 6ad2ef226c265d4c97dd7d2a8043e0115a7e314e (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
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;

  const createWrapper = (props = {}, { glAvatarForAllUserAvatars } = {}) => {
    wrapper = shallowMount(UserAvatarImage, {
      propsData: {
        ...PROVIDED_PROPS,
        ...props,
      },
      provide: {
        glFeatures: {
          glAvatarForAllUserAvatars,
        },
      },
    });
  };

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

  describe.each([
    [false, true, true],
    [true, false, true],
    [true, true, true],
    [false, false, false],
  ])(
    'when glAvatarForAllUserAvatars=%s and enforceGlAvatar=%s',
    (glAvatarForAllUserAvatars, enforceGlAvatar, isUsingNewVersion) => {
      it(`will render ${isUsingNewVersion ? 'new' : 'old'} version`, () => {
        createWrapper({ enforceGlAvatar }, { glAvatarForAllUserAvatars });
        expect(wrapper.findComponent(UserAvatarImageNew).exists()).toBe(isUsingNewVersion);
        expect(wrapper.findComponent(UserAvatarImageOld).exists()).toBe(!isUsingNewVersion);
      });
    },
  );
});