-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathfeedbackBoard.test.tsx
119 lines (108 loc) · 3.56 KB
/
feedbackBoard.test.tsx
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import React from 'react';
import { IFeedbackBoardDocument } from '../../interfaces/feedback';
import { shallow } from 'enzyme';
import { mocked } from 'jest-mock';
import FeedbackBoard, { FeedbackBoardProps } from '../../components/feedbackBoard';
import { testColumnProps } from '../__mocks__/mocked_components/mockedFeedbackColumn';
import { IdentityRef } from 'azure-devops-extension-api/WebApi';
jest.mock('../feedbackBoardMetadataForm', () => mocked({}));
jest.mock('azure-devops-extension-api/Work/WorkClient', () => {
const getTeamIterationsMock = () => {
return [
mocked({
attributes: mocked({
finishDate: new Date(),
startDate: new Date(),
timeFrame: 1,
}),
id: 'iterationId',
name: 'iteration name',
path: 'default path',
_links: [],
url: 'https://teamfieldvaluesurl'
})
];
};
const getTeamFieldValuesMock = () => {
return [
mocked({
defaultValue: 'default field value',
field: mocked({
referenceName: 'default reference name',
url: 'https://fieldurl'
}),
values: [
mocked({
includeChildren: false,
value: 'default team field value',
})
],
links: [],
url: 'https://teamfieldvaluesurl'
})]
};
const workRestClientMock = jest.fn().mockImplementation(() => ({
getTeamIterations: getTeamIterationsMock,
getTeamFieldValues: getTeamFieldValuesMock,
}));
return { WorkRestClient: workRestClientMock };
});
jest.mock('azure-devops-extension-api/WorkItemTracking/WorkItemTrackingClient', () => ({
WorkItemTrackingRestClient: jest.fn().mockImplementation(() => ({}))
}));
jest.mock('azure-devops-extension-api/Common', () => ({
getClient: (clientClass: typeof Object) => new clientClass(),
}));
const mockedIdentity: IdentityRef = {
directoryAlias: '',
id: '',
imageUrl: '',
inactive: false,
isAadIdentity: false,
isContainer: false,
isDeletedInOrigin: false,
profileUrl: '',
uniqueName: '',
_links: undefined,
descriptor: '',
displayName: '',
url: ''
};
const mockedBoard: IFeedbackBoardDocument = {
id: testColumnProps.boardId,
title: testColumnProps.boardTitle,
teamId: testColumnProps.team.id,
createdBy: mockedIdentity,
createdDate: new Date(),
columns: testColumnProps.columnIds.map((columnId) => testColumnProps.columns[columnId].columnProperties),
activePhase: 'Vote',
maxVotesPerUser: 5,
boardVoteCollection: {},
teamEffectivenessMeasurementVoteCollection: []
};
const mockedProps: FeedbackBoardProps = {
displayBoard: true,
board: mockedBoard,
team: testColumnProps.team,
workflowPhase: 'Vote',
nonHiddenWorkItemTypes: testColumnProps.nonHiddenWorkItemTypes,
allWorkItemTypes: testColumnProps.allWorkItemTypes,
isAnonymous: testColumnProps.isBoardAnonymous,
hideFeedbackItems: testColumnProps.hideFeedbackItems,
isCarouselDialogHidden: false,
hideCarouselDialog: jest.fn(() => { }),
userId: ''
};
describe(`The Feedback Board Component`, () => {
it(`can be rendered`, () => {
const wrapper = shallow(<FeedbackBoard {...mockedProps} />);
const component = wrapper.children().dive();
expect(component.prop('className')).toBe('feedback-board');
});
it(`shows correct vote counts`, () => {
const wrapper = shallow(<FeedbackBoard {...mockedProps} />);
const component = wrapper.children().dive();
expect(component.findWhere((child) => child.prop("className") === "feedback-maxvotes-per-user").text())
.toBe('Votes Used: 0 / 5 (me), 0 / 0 (team)');
});
});