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

utils_spec.js « user_deletion_obstacles « components « vue_shared « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 99f739098f7d00034c8dd7848a6f47980e96045d (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
import { OBSTACLE_TYPES } from '~/vue_shared/components/user_deletion_obstacles/constants';
import { parseUserDeletionObstacles } from '~/vue_shared/components/user_deletion_obstacles/utils';

describe('parseUserDeletionObstacles', () => {
  const mockObstacles = [{ name: 'Obstacle' }];
  const expectedSchedule = { name: 'Obstacle', type: OBSTACLE_TYPES.oncallSchedules };
  const expectedPolicy = { name: 'Obstacle', type: OBSTACLE_TYPES.escalationPolicies };

  it('is undefined when user is not available', () => {
    expect(parseUserDeletionObstacles()).toHaveLength(0);
  });

  it('is empty when obstacles are not available for user', () => {
    expect(parseUserDeletionObstacles({})).toHaveLength(0);
  });

  it('is empty when user has no obstacles to deletion', () => {
    const input = { oncallSchedules: [], escalationPolicies: [] };

    expect(parseUserDeletionObstacles(input)).toHaveLength(0);
  });

  it('returns obstacles with type when user is part of on-call schedules', () => {
    const input = { oncallSchedules: mockObstacles, escalationPolicies: [] };
    const expectedOutput = [expectedSchedule];

    expect(parseUserDeletionObstacles(input)).toEqual(expectedOutput);
  });

  it('returns obstacles with type when user is part of escalation policies', () => {
    const input = { oncallSchedules: [], escalationPolicies: mockObstacles };
    const expectedOutput = [expectedPolicy];

    expect(parseUserDeletionObstacles(input)).toEqual(expectedOutput);
  });

  it('returns obstacles with type when user have every obstacle type', () => {
    const input = { oncallSchedules: mockObstacles, escalationPolicies: mockObstacles };
    const expectedOutput = [expectedSchedule, expectedPolicy];

    expect(parseUserDeletionObstacles(input)).toEqual(expectedOutput);
  });
});