@reltio/components 1.4.1906 → 1.4.1907
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/ActionsPanel/ActionsPanel.test.js +133 -49
- package/cjs/AttributeListItem/AttributeListItem.spec.js +147 -118
- package/cjs/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/cjs/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/cjs/AttributesErrorsPanel/components/Error/Error.specs.js +96 -90
- package/cjs/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/cjs/AttributesErrorsPanel/store.test-data.js +29 -0
- package/cjs/AttributesFilterSelector/AttributesFilterSelector.test.js +127 -105
- package/cjs/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/cjs/AttributesValuesEditor/AttributesValuesEditor.test.js +92 -88
- package/cjs/AttributesView/AttributesView.test.js +67 -34
- package/cjs/AutoSizeList/AutoSizeList.test.js +81 -59
- package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +15 -31
- package/cjs/BarChart/BarChart.test.js +128 -65
- package/cjs/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/cjs/BasicViewContent/BasicViewContent.test.js +7 -9
- package/cjs/BlobRenderer/BlobRenderer.test.js +28 -9
- package/cjs/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/cjs/BubbleChart/BubbleChart.test.js +111 -87
- package/cjs/CloudChart/CloudChart.test.js +95 -36
- package/cjs/CollaborationItem/CollaborationItem.test.js +67 -30
- package/cjs/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/cjs/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -81
- package/cjs/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/cjs/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/cjs/CollapseButton/CollapseButton.test.js +74 -15
- package/cjs/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/cjs/ColorBar/ColorBar.test.js +13 -15
- package/cjs/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/cjs/CommentsContainer/CommentsContainer.test.js +282 -211
- package/cjs/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +183 -122
- package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/cjs/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/cjs/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/cjs/ConnectionEditor/ConnectionEditor.test.js +299 -282
- package/esm/ActionsPanel/ActionsPanel.test.js +133 -49
- package/esm/AttributeListItem/AttributeListItem.spec.js +149 -97
- package/esm/AttributeSelector/AttributeSelector.specs.js +125 -193
- package/esm/AttributesErrorsPanel/AttributesErrorsPanel.specs.js +128 -71
- package/esm/AttributesErrorsPanel/components/Error/Error.specs.js +98 -72
- package/esm/AttributesErrorsPanel/store.test-data.d.ts +22 -0
- package/esm/AttributesErrorsPanel/store.test-data.js +26 -0
- package/esm/AttributesFilterSelector/AttributesFilterSelector.test.js +129 -84
- package/esm/AttributesFiltersButton/AttributesFiltersButton.test.js +218 -136
- package/esm/AttributesValuesEditor/AttributesValuesEditor.test.js +94 -67
- package/esm/AttributesView/AttributesView.test.js +67 -34
- package/esm/AutoSizeList/AutoSizeList.test.js +81 -59
- package/esm/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.js → AvatarWithFallback/AvatarWithFallback.test.js} +16 -32
- package/esm/BarChart/BarChart.test.js +128 -65
- package/esm/BasicAttributeSelector/BasicAttributeSelector.spec.js +27 -10
- package/esm/BasicViewContent/BasicViewContent.test.js +7 -9
- package/esm/BlobRenderer/BlobRenderer.test.js +28 -9
- package/esm/BooleanRadioEditor/BooleanRadioEditor.test.js +89 -35
- package/esm/BubbleChart/BubbleChart.test.js +111 -87
- package/esm/CloudChart/CloudChart.test.js +95 -36
- package/esm/CollaborationItem/CollaborationItem.test.js +67 -30
- package/esm/CollaborationItem/components/Comment/Comment.test.js +221 -189
- package/esm/CollaborationItem/components/CommentContent/CommentContent.test.js +46 -58
- package/esm/CollaborationItem/components/RepliedComment/RepliedComment.test.js +194 -163
- package/esm/CollaborationItem/components/SendMessageArea/SendMessageArea.test.js +307 -266
- package/esm/CollapseButton/CollapseButton.test.js +74 -15
- package/esm/CollapseRowButton/CollapseRowButton.test.js +82 -24
- package/esm/ColorBar/ColorBar.test.js +13 -15
- package/esm/ColumnsSettings/components/ColumnsSettingsPopup/ColumnsSettingsPopup.spec.js +207 -129
- package/esm/CommentsContainer/CommentsContainer.test.js +282 -211
- package/esm/CommentsContainer/components/CollaborationPopup/CollaborationPopup.test.js +182 -101
- package/esm/ConfigureColumnsPopup/ConfigureColumnsPopup.test.js +42 -41
- package/esm/ConfirmDeleteDialog/ConfirmDeleteDialog.test.js +77 -28
- package/esm/ConfirmationDialog/ConfirmationDialog.test.js +85 -48
- package/esm/ConnectionEditor/ConnectionEditor.test.js +300 -283
- package/package.json +1 -1
- package/cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -100
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/cjs/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -46
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/cjs/AvatarWithFallback/AvatarWithFallback.specs.js +0 -27
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/cjs/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -27
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/Avatar/Avatar.test.js +0 -15
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/cjs/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -80
- package/esm/ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts +0 -1
- package/esm/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.js +0 -95
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.d.ts +0 -1
- package/esm/AttributesFiltersButton/components/ActionButtons/ActionButtons.test.js +0 -41
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.d.ts +0 -1
- package/esm/AvatarWithFallback/AvatarWithFallback.specs.js +0 -22
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.d.ts +0 -1
- package/esm/BooleanRadioEditor/components/BooleanEditor/BooleanEditor.test.js +0 -22
- package/esm/CollaborationItem/components/Avatar/Avatar.test.d.ts +0 -1
- package/esm/CollaborationItem/components/Avatar/Avatar.test.js +0 -10
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.d.ts +0 -1
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.test.js +0 -55
- /package/cjs/{ActionsPanel/components/MenuItemRenderer/MenuItemRenderer.spec.d.ts → AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
- /package/{cjs/AttributesErrorsPanel/components/ErrorsPanel/ErrorsPanel.specs.d.ts → esm/AvatarWithFallback/AvatarWithFallback.test.d.ts} +0 -0
|
@@ -51,202 +51,262 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
51
51
|
};
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
var react_1 = __importDefault(require("react"));
|
|
54
|
-
var
|
|
55
|
-
var test_utils_1 = require("react-dom/test-utils");
|
|
54
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
56
55
|
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
57
56
|
var CollaborationContext_1 = require("../../../contexts/CollaborationContext");
|
|
58
|
-
var TextFieldWithMentions_1 = require("../TextFieldWithMentions");
|
|
59
|
-
var Avatar_1 = require("../Avatar");
|
|
60
57
|
var SendMessageArea_1 = require("./SendMessageArea");
|
|
61
|
-
var
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var defaultGetCommentState = jest.fn().mockImplementation(function () { return ({}); });
|
|
70
|
-
var clearCommentState = jest.fn();
|
|
71
|
-
var updateCommentState = jest.fn();
|
|
72
|
-
var createCommentObject = function (_a) {
|
|
73
|
-
var _b = _a === void 0 ? {} : _a, status = _b.status;
|
|
74
|
-
return {
|
|
75
|
-
commentId: 'commentId',
|
|
76
|
-
status: status
|
|
58
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
59
|
+
var react_2 = require("@testing-library/react");
|
|
60
|
+
var ramda_1 = require("ramda");
|
|
61
|
+
describe('SendMessageArea tests', function () {
|
|
62
|
+
var mdmValues = {
|
|
63
|
+
user: {
|
|
64
|
+
username: 'egor.ivanov'
|
|
65
|
+
}
|
|
77
66
|
};
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
createComment:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
67
|
+
var createCommentObject = function (commentObject) {
|
|
68
|
+
if (commentObject === void 0) { commentObject = {}; }
|
|
69
|
+
return __assign({ selfLink: 'selfLink', commentId: 'commentId', createdBy: 'created by user', createdTime: 1, modifiedTime: 2, deleted: false, visibility: 'visible', objectId: 'id1', objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY, permanentLink: 'permanentLink', content: 'commentContent', namedUsers: ['user1'], replies: [], relatedObjectUris: ['uri1'], status: 'open' }, commentObject);
|
|
70
|
+
};
|
|
71
|
+
var createCollaborationContext = function (props) {
|
|
72
|
+
if (props === void 0) { props = {}; }
|
|
73
|
+
return __assign({ comments: [], commentsMap: null, currentComment: null, getComment: ramda_1.identity, getComments: function () { return new Promise(ramda_1.identity); }, getCommentsCount: ramda_1.identity, resolveThread: ramda_1.identity, reOpenThread: ramda_1.identity, clearCurrentComment: ramda_1.identity, deleteComment: ramda_1.identity, sending: false, loading: false, pageToken: null, deleteReply: ramda_1.identity, createReply: function () { return new Promise(function (res) { return res(); }); }, createComment: function () { return new Promise(function (res) { return res(); }); }, editComment: function () { return new Promise(function (res) { return res(); }); }, editReply: function () { return new Promise(function (res) { return res(); }); }, getCommentState: function () { return ({}); }, clearCommentState: function () { }, updateCommentState: function () { } }, props);
|
|
74
|
+
};
|
|
75
|
+
var createProps = function (comment, extraProps) {
|
|
76
|
+
if (extraProps === void 0) { extraProps = {}; }
|
|
77
|
+
return __assign(__assign({ comment: comment, inputRef: react_1.default.createRef() }, extraProps), { objectType: mdm_sdk_1.CollaborationObjectTypes.ENTITY, uri: 'uri', relatedObjectUris: ['entities/13JKIKAz'], className: 'root' });
|
|
78
|
+
};
|
|
79
|
+
var setUp = function (_a) {
|
|
80
|
+
var props = _a.props, _b = _a.collaborationContextValue, collaborationContextValue = _b === void 0 ? createCollaborationContext() : _b;
|
|
81
|
+
var Providers = function (_a) {
|
|
82
|
+
var children = _a.children;
|
|
83
|
+
return (react_1.default.createElement(CollaborationContext_1.CollaborationContext.Provider, { value: collaborationContextValue },
|
|
84
|
+
react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues }, children)));
|
|
85
|
+
};
|
|
86
|
+
var user = user_event_1.default.setup();
|
|
87
|
+
return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(SendMessageArea_1.SendMessageArea, __assign({}, props)), { wrapper: Providers }));
|
|
91
88
|
};
|
|
92
|
-
};
|
|
93
|
-
var user = {
|
|
94
|
-
username: 'egor.ivanov'
|
|
95
|
-
};
|
|
96
|
-
var setUp = function (props) {
|
|
97
|
-
return (0, enzyme_1.mount)(react_1.default.createElement(CollaborationContext_1.CollaborationContext.Provider, { value: collaborationContextValue },
|
|
98
|
-
react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: { user: user } },
|
|
99
|
-
react_1.default.createElement(SendMessageArea_1.SendMessageArea, __assign({}, props)))));
|
|
100
|
-
};
|
|
101
|
-
describe('SendMessageArea tests', function () {
|
|
102
|
-
afterEach(function () {
|
|
103
|
-
jest.clearAllMocks();
|
|
104
|
-
});
|
|
105
89
|
it('should render avatar correctly', function () {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
expect(
|
|
90
|
+
setUp({
|
|
91
|
+
props: createProps(createCommentObject({ status: 'open' }))
|
|
92
|
+
});
|
|
93
|
+
expect(react_2.screen.queryByText('EI')).toBeInTheDocument();
|
|
110
94
|
});
|
|
111
95
|
it('should render input correctly if status is "open"', function () {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
expect(
|
|
96
|
+
setUp({
|
|
97
|
+
props: createProps(createCommentObject({ status: 'open' }))
|
|
98
|
+
});
|
|
99
|
+
expect(react_2.screen.queryByPlaceholderText('Reply...')).toBeInTheDocument();
|
|
116
100
|
});
|
|
117
101
|
it('should render input correctly if status is "resolved"', function () {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
expect(
|
|
102
|
+
setUp({
|
|
103
|
+
props: createProps(createCommentObject({ status: 'resolved' }))
|
|
104
|
+
});
|
|
105
|
+
expect(react_2.screen.queryByPlaceholderText('Adding a comment will re-open this')).toBeInTheDocument();
|
|
122
106
|
});
|
|
123
107
|
it('should render input correctly if status is undefined', function () {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
expect(
|
|
128
|
-
});
|
|
129
|
-
it('should render Reply button correctly if status is "open"', function () {
|
|
130
|
-
mockCollaborationContext();
|
|
131
|
-
var component = setUp(createProps(createCommentObject({ status: 'open' })));
|
|
132
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
133
|
-
var buttons = component.find('.buttons').last();
|
|
134
|
-
expect(buttons.childAt(0).text()).toBe('Reply');
|
|
135
|
-
});
|
|
136
|
-
it('should render Reply button correctly if status is "resolved"', function () {
|
|
137
|
-
mockCollaborationContext();
|
|
138
|
-
var component = setUp(createProps(createCommentObject({ status: 'resolved' })));
|
|
139
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
140
|
-
var buttons = component.find('.buttons').last();
|
|
141
|
-
expect(buttons.childAt(0).text()).toBe('Reply');
|
|
142
|
-
});
|
|
143
|
-
it('should render Comment button correctly if comment is undefined', function () {
|
|
144
|
-
mockCollaborationContext();
|
|
145
|
-
var component = setUp(createProps());
|
|
146
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
147
|
-
var buttons = component.find('.buttons').last();
|
|
148
|
-
expect(buttons.childAt(0).text()).toBe('Comment');
|
|
108
|
+
setUp({
|
|
109
|
+
props: createProps()
|
|
110
|
+
});
|
|
111
|
+
expect(react_2.screen.getByRole('textbox')).toHaveAttribute('placeholder', '');
|
|
149
112
|
});
|
|
113
|
+
it('should render Reply button correctly if status is "open"', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
var user;
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (_a.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
user = setUp({
|
|
119
|
+
props: createProps(createCommentObject({ status: 'open' }))
|
|
120
|
+
}).user;
|
|
121
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('textbox'))];
|
|
122
|
+
case 1:
|
|
123
|
+
_a.sent();
|
|
124
|
+
expect(react_2.screen.getByRole('button', { name: 'Reply' })).toBeInTheDocument();
|
|
125
|
+
return [2 /*return*/];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}); });
|
|
129
|
+
it('should render Reply button correctly if status is "resolved"', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
+
var user;
|
|
131
|
+
return __generator(this, function (_a) {
|
|
132
|
+
switch (_a.label) {
|
|
133
|
+
case 0:
|
|
134
|
+
user = setUp({
|
|
135
|
+
props: createProps(createCommentObject({ status: 'resolved' }))
|
|
136
|
+
}).user;
|
|
137
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('textbox'))];
|
|
138
|
+
case 1:
|
|
139
|
+
_a.sent();
|
|
140
|
+
expect(react_2.screen.getByRole('button', { name: 'Reply' })).toBeInTheDocument();
|
|
141
|
+
return [2 /*return*/];
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}); });
|
|
145
|
+
it('should render Comment button correctly if comment is undefined', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var user;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
user = setUp({
|
|
151
|
+
props: createProps()
|
|
152
|
+
}).user;
|
|
153
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('textbox'))];
|
|
154
|
+
case 1:
|
|
155
|
+
_a.sent();
|
|
156
|
+
expect(react_2.screen.getByRole('button', { name: 'Comment' })).toBeInTheDocument();
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); });
|
|
150
161
|
it('should render buttons if value is not empty string', function () {
|
|
151
162
|
var getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
152
163
|
value: 'value',
|
|
153
164
|
plainTextValue: 'value',
|
|
154
165
|
mentions: []
|
|
155
166
|
}); });
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
mockCollaborationContext();
|
|
162
|
-
var component = setUp(createProps(createCommentObject({ status: 'open' })));
|
|
163
|
-
expect(component.find('.buttons')).toHaveLength(0);
|
|
164
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
165
|
-
expect(component.find('.buttons').length).toBeTruthy();
|
|
166
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('blur');
|
|
167
|
-
expect(component.find('.buttons')).toHaveLength(0);
|
|
168
|
-
});
|
|
169
|
-
it('should disable Reply or Comment button if value is empty', function () {
|
|
170
|
-
var getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
171
|
-
value: 'value',
|
|
172
|
-
plainTextValue: 'value',
|
|
173
|
-
mentions: []
|
|
174
|
-
}); });
|
|
175
|
-
mockCollaborationContext({ getCommentState: getCommentState });
|
|
176
|
-
var component = setUp(createProps(createCommentObject({ status: 'open' })));
|
|
177
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
178
|
-
var buttons = component.find('.buttons').last();
|
|
179
|
-
expect(buttons.childAt(0).prop('disabled')).toBe(false);
|
|
180
|
-
});
|
|
181
|
-
it('should disable Cancel button if loading is "true"', function () {
|
|
182
|
-
mockCollaborationContext({ sending: true });
|
|
183
|
-
var component = setUp(createProps(createCommentObject({ status: 'open' })));
|
|
184
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
185
|
-
var buttons = component.find('.buttons').last();
|
|
186
|
-
expect(buttons.childAt(1).prop('disabled')).toBe(true);
|
|
167
|
+
setUp({
|
|
168
|
+
props: createProps(),
|
|
169
|
+
collaborationContextValue: createCollaborationContext({ getCommentState: getCommentState })
|
|
170
|
+
});
|
|
171
|
+
expect(react_2.screen.queryAllByRole('button')).toHaveLength(2);
|
|
187
172
|
});
|
|
188
|
-
it('should
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
173
|
+
it('should render buttons if input is focused', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
174
|
+
var user;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
user = setUp({
|
|
179
|
+
props: createProps(createCommentObject({ status: 'open' }))
|
|
180
|
+
}).user;
|
|
181
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('textbox'))];
|
|
182
|
+
case 1:
|
|
183
|
+
_a.sent();
|
|
184
|
+
expect(react_2.screen.queryAllByRole('button')).toHaveLength(2);
|
|
185
|
+
return [4 /*yield*/, user_event_1.default.tab()];
|
|
186
|
+
case 2:
|
|
187
|
+
_a.sent();
|
|
188
|
+
expect(react_2.screen.queryAllByRole('button')).toHaveLength(0);
|
|
189
|
+
return [2 /*return*/];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}); });
|
|
193
|
+
it('should disable Reply or Comment button if value is empty', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
194
|
+
var getCommentState, user;
|
|
195
|
+
return __generator(this, function (_a) {
|
|
196
|
+
switch (_a.label) {
|
|
197
|
+
case 0:
|
|
198
|
+
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
199
|
+
value: '',
|
|
200
|
+
plainTextValue: '',
|
|
201
|
+
mentions: []
|
|
202
|
+
}); });
|
|
203
|
+
user = setUp({
|
|
204
|
+
props: createProps(createCommentObject({ status: 'open' })),
|
|
205
|
+
collaborationContextValue: createCollaborationContext({ getCommentState: getCommentState })
|
|
206
|
+
}).user;
|
|
207
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('textbox'))];
|
|
208
|
+
case 1:
|
|
209
|
+
_a.sent();
|
|
210
|
+
expect(react_2.screen.queryByRole('button', { name: 'Reply' })).toBeDisabled();
|
|
211
|
+
return [2 /*return*/];
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}); });
|
|
215
|
+
it('should disable Cancel button if sending is "true"', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
216
|
+
return __generator(this, function (_a) {
|
|
217
|
+
setUp({
|
|
218
|
+
props: createProps(createCommentObject({ status: 'open' })),
|
|
219
|
+
collaborationContextValue: createCollaborationContext({ sending: true })
|
|
220
|
+
});
|
|
221
|
+
react_2.fireEvent.focus(react_2.screen.getByRole('textbox'));
|
|
222
|
+
expect(react_2.screen.queryByRole('button', { name: 'Cancel' })).toBeDisabled();
|
|
223
|
+
return [2 /*return*/];
|
|
224
|
+
});
|
|
225
|
+
}); });
|
|
226
|
+
it('should disable Reply or Comment button if sending is "true"', function () {
|
|
227
|
+
setUp({
|
|
228
|
+
props: createProps(createCommentObject({ status: 'open' })),
|
|
229
|
+
collaborationContextValue: createCollaborationContext({ sending: true })
|
|
230
|
+
});
|
|
231
|
+
react_2.fireEvent.focus(react_2.screen.getByRole('textbox'));
|
|
232
|
+
expect(react_2.screen.queryByRole('button', { name: 'Reply' })).toBeDisabled();
|
|
194
233
|
});
|
|
195
234
|
it('should pass correct default value to TextFieldWithMentions if isEditingComment equals true', function () {
|
|
196
|
-
mockCollaborationContext();
|
|
197
235
|
var comment = {
|
|
198
236
|
content: 'Hello +denis',
|
|
199
|
-
namedUsers: ['denis']
|
|
200
|
-
commentId: 'commentId',
|
|
201
|
-
status: 'open'
|
|
237
|
+
namedUsers: ['denis']
|
|
202
238
|
};
|
|
203
|
-
|
|
204
|
-
|
|
239
|
+
setUp({
|
|
240
|
+
props: createProps(createCommentObject(comment), { isEditingComment: true })
|
|
241
|
+
});
|
|
242
|
+
expect(react_2.screen.getByPlaceholderText('Reply...')).toHaveTextContent('Hello +denis');
|
|
205
243
|
});
|
|
206
244
|
it('should pass correct default value to TextFieldWithMentions if isEditingReply equals true', function () {
|
|
207
|
-
mockCollaborationContext();
|
|
208
245
|
var reply = {
|
|
209
246
|
content: 'Hello +ainsteisha',
|
|
210
247
|
namedUsers: ['ainsteisha'],
|
|
211
248
|
replyId: 'replyId'
|
|
212
249
|
};
|
|
213
|
-
|
|
214
|
-
|
|
250
|
+
setUp({
|
|
251
|
+
props: createProps(createCommentObject(), { isEditingReply: true, reply: reply })
|
|
252
|
+
});
|
|
253
|
+
expect(react_2.screen.getByPlaceholderText('Reply...')).toHaveTextContent('Hello +ainsteisha');
|
|
215
254
|
});
|
|
216
255
|
it('should pass correct default value to TextFieldWithMentions if isEditingReply and isEditingComment equals false', function () {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
expect(component.find(TextFieldWithMentions_1.TextFieldWithMentions).prop('value')).toBe('');
|
|
220
|
-
});
|
|
221
|
-
it('handleChange handler should work correctly', function () {
|
|
222
|
-
mockCollaborationContext();
|
|
223
|
-
var component = setUp(createProps());
|
|
224
|
-
var onChange = component.find(TextFieldWithMentions_1.TextFieldWithMentions).prop('onChange');
|
|
225
|
-
var value = 'Hello @[+vyacheslav](vyacheslav)';
|
|
226
|
-
var plainTextValue = 'Hello +vyacheslav';
|
|
227
|
-
var mentions = ['vyacheslav'];
|
|
228
|
-
(0, test_utils_1.act)(function () {
|
|
229
|
-
onChange === null || onChange === void 0 ? void 0 : onChange(value, plainTextValue, mentions);
|
|
256
|
+
setUp({
|
|
257
|
+
props: createProps(createCommentObject())
|
|
230
258
|
});
|
|
231
|
-
expect(
|
|
259
|
+
expect(react_2.screen.getByPlaceholderText('Reply...')).toHaveTextContent('');
|
|
232
260
|
});
|
|
261
|
+
it('handleChange handler should work correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
262
|
+
var value, plainTextValue, mentions, getCommentState, updateCommentState, user;
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
switch (_a.label) {
|
|
265
|
+
case 0:
|
|
266
|
+
value = 'Hello @[vyacheslav](vyacheslav)';
|
|
267
|
+
plainTextValue = 'Hello +vyacheslav';
|
|
268
|
+
mentions = ['vyacheslav'];
|
|
269
|
+
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
270
|
+
value: value,
|
|
271
|
+
plainTextValue: plainTextValue,
|
|
272
|
+
mentions: mentions
|
|
273
|
+
}); });
|
|
274
|
+
updateCommentState = jest.fn();
|
|
275
|
+
user = setUp({
|
|
276
|
+
props: createProps(),
|
|
277
|
+
collaborationContextValue: createCollaborationContext({ getCommentState: getCommentState, updateCommentState: updateCommentState })
|
|
278
|
+
}).user;
|
|
279
|
+
return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), ' ')];
|
|
280
|
+
case 1:
|
|
281
|
+
_a.sent();
|
|
282
|
+
expect(updateCommentState).toHaveBeenCalledWith('uri', 'comment/new', {
|
|
283
|
+
value: "".concat(value, " "),
|
|
284
|
+
plainTextValue: "".concat(plainTextValue, " "),
|
|
285
|
+
mentions: mentions
|
|
286
|
+
});
|
|
287
|
+
return [2 /*return*/];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}); });
|
|
233
291
|
it('handleSubmit handler should work correctly if comment exists and last status is "open"', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
234
|
-
var getCommentState,
|
|
292
|
+
var getCommentState, clearCommentState, createReply, user;
|
|
235
293
|
return __generator(this, function (_a) {
|
|
236
294
|
switch (_a.label) {
|
|
237
295
|
case 0:
|
|
238
296
|
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
239
|
-
value: 'Hello @[
|
|
297
|
+
value: 'Hello @[vyacheslav](vyacheslav)',
|
|
240
298
|
plainTextValue: 'Hello +vyacheslav',
|
|
241
299
|
mentions: ['vyacheslav']
|
|
242
300
|
}); });
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
301
|
+
clearCommentState = jest.fn();
|
|
302
|
+
createReply = jest.fn().mockReturnValue(new Promise(function (res) { return res(); }));
|
|
303
|
+
user = setUp({
|
|
304
|
+
props: createProps(createCommentObject({ status: 'open' })),
|
|
305
|
+
collaborationContextValue: createCollaborationContext({ getCommentState: getCommentState, createReply: createReply, clearCommentState: clearCommentState })
|
|
306
|
+
}).user;
|
|
307
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Reply' }))];
|
|
308
|
+
case 1:
|
|
309
|
+
_a.sent();
|
|
250
310
|
expect(createReply).toHaveBeenCalledWith({
|
|
251
311
|
content: 'Hello +vyacheslav',
|
|
252
312
|
namedUsers: ['vyacheslav'],
|
|
@@ -254,36 +314,30 @@ describe('SendMessageArea tests', function () {
|
|
|
254
314
|
action: 'none',
|
|
255
315
|
uri: 'uri'
|
|
256
316
|
});
|
|
257
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
258
|
-
return __generator(this, function (_a) {
|
|
259
|
-
component.update();
|
|
260
|
-
return [2 /*return*/];
|
|
261
|
-
});
|
|
262
|
-
}); })];
|
|
263
|
-
case 1:
|
|
264
|
-
_a.sent();
|
|
265
317
|
expect(clearCommentState).toHaveBeenCalledWith('uri', 'comment/commentId/reply/new');
|
|
266
318
|
return [2 /*return*/];
|
|
267
319
|
}
|
|
268
320
|
});
|
|
269
321
|
}); });
|
|
270
322
|
it('handleSubmit handler should work correctly if comment exists and last status is "resolved"', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
271
|
-
var getCommentState,
|
|
323
|
+
var getCommentState, createReply, clearCommentState, user;
|
|
272
324
|
return __generator(this, function (_a) {
|
|
273
325
|
switch (_a.label) {
|
|
274
326
|
case 0:
|
|
275
327
|
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
276
|
-
value: 'Hello @[
|
|
328
|
+
value: 'Hello @[vyacheslav](vyacheslav)',
|
|
277
329
|
plainTextValue: 'Hello +vyacheslav',
|
|
278
330
|
mentions: ['vyacheslav']
|
|
279
331
|
}); });
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
332
|
+
createReply = jest.fn().mockReturnValue(new Promise(function (res) { return res(); }));
|
|
333
|
+
clearCommentState = jest.fn();
|
|
334
|
+
user = setUp({
|
|
335
|
+
props: createProps(createCommentObject({ status: 'resolved' })),
|
|
336
|
+
collaborationContextValue: createCollaborationContext({ getCommentState: getCommentState, createReply: createReply, clearCommentState: clearCommentState })
|
|
337
|
+
}).user;
|
|
338
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Reply' }))];
|
|
339
|
+
case 1:
|
|
340
|
+
_a.sent();
|
|
287
341
|
expect(createReply).toHaveBeenCalledWith({
|
|
288
342
|
content: 'Hello +vyacheslav',
|
|
289
343
|
namedUsers: ['vyacheslav'],
|
|
@@ -291,99 +345,86 @@ describe('SendMessageArea tests', function () {
|
|
|
291
345
|
action: 'reopen',
|
|
292
346
|
uri: 'uri'
|
|
293
347
|
});
|
|
294
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
295
|
-
return __generator(this, function (_a) {
|
|
296
|
-
component.update();
|
|
297
|
-
return [2 /*return*/];
|
|
298
|
-
});
|
|
299
|
-
}); })];
|
|
300
|
-
case 1:
|
|
301
|
-
_a.sent();
|
|
302
348
|
expect(clearCommentState).toHaveBeenCalledWith('uri', 'comment/commentId/reply/new');
|
|
303
349
|
return [2 /*return*/];
|
|
304
350
|
}
|
|
305
351
|
});
|
|
306
352
|
}); });
|
|
307
353
|
it('handleSubmit handler should work correctly if comment does not exist', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
308
|
-
var getCommentState,
|
|
354
|
+
var getCommentState, clearCommentState, createComment, user;
|
|
309
355
|
return __generator(this, function (_a) {
|
|
310
356
|
switch (_a.label) {
|
|
311
357
|
case 0:
|
|
312
358
|
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
313
|
-
value: 'Hello @[
|
|
359
|
+
value: 'Hello @[vyacheslav](vyacheslav)',
|
|
314
360
|
plainTextValue: 'Hello +vyacheslav',
|
|
315
361
|
mentions: ['vyacheslav']
|
|
316
362
|
}); });
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
363
|
+
clearCommentState = jest.fn();
|
|
364
|
+
createComment = jest.fn().mockReturnValue(new Promise(function (res) { return res(); }));
|
|
365
|
+
user = setUp({
|
|
366
|
+
props: createProps(),
|
|
367
|
+
collaborationContextValue: createCollaborationContext({ getCommentState: getCommentState, createComment: createComment, clearCommentState: clearCommentState })
|
|
368
|
+
}).user;
|
|
369
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Comment' }))];
|
|
370
|
+
case 1:
|
|
371
|
+
_a.sent();
|
|
324
372
|
expect(createComment).toHaveBeenCalledWith({
|
|
325
373
|
content: 'Hello +vyacheslav',
|
|
326
374
|
namedUsers: ['vyacheslav'],
|
|
327
|
-
objectType: '
|
|
375
|
+
objectType: 'entity',
|
|
328
376
|
uri: 'uri',
|
|
329
377
|
relatedObjectUris: ['entities/13JKIKAz']
|
|
330
378
|
});
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
379
|
+
expect(clearCommentState).toHaveBeenCalledWith('uri', 'comment/new');
|
|
380
|
+
return [2 /*return*/];
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}); });
|
|
384
|
+
it('should render Edit button if isEditingComment prop is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
385
|
+
var user;
|
|
386
|
+
return __generator(this, function (_a) {
|
|
387
|
+
switch (_a.label) {
|
|
388
|
+
case 0:
|
|
389
|
+
user = setUp({
|
|
390
|
+
props: createProps(createCommentObject({ status: 'resolved' }), { isEditingComment: true })
|
|
391
|
+
}).user;
|
|
392
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('textbox'))];
|
|
337
393
|
case 1:
|
|
338
394
|
_a.sent();
|
|
339
|
-
expect(
|
|
395
|
+
expect(react_2.screen.queryByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
340
396
|
return [2 /*return*/];
|
|
341
397
|
}
|
|
342
398
|
});
|
|
343
399
|
}); });
|
|
344
|
-
it('should render Edit button if isEditingComment prop is true', function () {
|
|
345
|
-
mockCollaborationContext();
|
|
346
|
-
var component = setUp(createProps(createCommentObject({ status: 'resolved' }), { isEditingComment: true }));
|
|
347
|
-
component.find(TextFieldWithMentions_1.TextFieldWithMentions).find('textarea').simulate('focus');
|
|
348
|
-
var buttons = component.find('.buttons').last();
|
|
349
|
-
expect(buttons.childAt(0).text()).toBe('Edit');
|
|
350
|
-
});
|
|
351
400
|
it('submitting should work correctly if comment is editing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
352
|
-
var onCancel,
|
|
401
|
+
var onCancel, editComment, clearCommentState, comment, user;
|
|
353
402
|
return __generator(this, function (_a) {
|
|
354
403
|
switch (_a.label) {
|
|
355
404
|
case 0:
|
|
356
|
-
mockCollaborationContext();
|
|
357
405
|
onCancel = jest.fn();
|
|
406
|
+
editComment = jest.fn().mockReturnValue(new Promise(function (res) { return res(); }));
|
|
407
|
+
clearCommentState = jest.fn();
|
|
358
408
|
comment = {
|
|
359
409
|
content: 'Hello +denis',
|
|
360
|
-
namedUsers: ['denis']
|
|
361
|
-
commentId: 'commentId',
|
|
362
|
-
status: 'open'
|
|
410
|
+
namedUsers: ['denis']
|
|
363
411
|
};
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
412
|
+
user = setUp({
|
|
413
|
+
props: createProps(createCommentObject(comment), { isEditingComment: true, onCancel: onCancel }),
|
|
414
|
+
collaborationContextValue: createCollaborationContext({ editComment: editComment, clearCommentState: clearCommentState })
|
|
415
|
+
}).user;
|
|
416
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Edit' }))];
|
|
417
|
+
case 1:
|
|
418
|
+
_a.sent();
|
|
419
|
+
expect(editComment).toHaveBeenCalledWith({
|
|
371
420
|
content: 'Hello +denis',
|
|
372
421
|
namedUsers: ['denis'],
|
|
373
422
|
commentId: 'commentId',
|
|
374
423
|
uri: 'uri',
|
|
375
424
|
relatedObjectUris: ['entities/13JKIKAz'],
|
|
376
|
-
replies:
|
|
377
|
-
objectType: '
|
|
425
|
+
replies: [],
|
|
426
|
+
objectType: 'entity'
|
|
378
427
|
});
|
|
379
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
380
|
-
return __generator(this, function (_a) {
|
|
381
|
-
component.update();
|
|
382
|
-
return [2 /*return*/];
|
|
383
|
-
});
|
|
384
|
-
}); })];
|
|
385
|
-
case 1:
|
|
386
|
-
_a.sent();
|
|
387
428
|
expect(clearCommentState).toHaveBeenCalledWith('uri', 'comment/commentId');
|
|
388
429
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
389
430
|
return [2 /*return*/];
|
|
@@ -391,41 +432,35 @@ describe('SendMessageArea tests', function () {
|
|
|
391
432
|
});
|
|
392
433
|
}); });
|
|
393
434
|
it('submitting should work correctly if reply is editing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
394
|
-
var onCancel,
|
|
435
|
+
var onCancel, editReply, clearCommentState, reply, user;
|
|
395
436
|
return __generator(this, function (_a) {
|
|
396
437
|
switch (_a.label) {
|
|
397
438
|
case 0:
|
|
398
|
-
mockCollaborationContext();
|
|
399
439
|
onCancel = jest.fn();
|
|
440
|
+
editReply = jest.fn().mockReturnValue(new Promise(function (res) { return res(); }));
|
|
441
|
+
clearCommentState = jest.fn();
|
|
400
442
|
reply = {
|
|
401
443
|
content: 'Hello +ainsteisha',
|
|
402
444
|
namedUsers: ['ainsteisha'],
|
|
403
445
|
replyId: 'replyId'
|
|
404
446
|
};
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
447
|
+
user = setUp({
|
|
448
|
+
props: createProps(createCommentObject(), {
|
|
449
|
+
isEditingReply: true,
|
|
450
|
+
onCancel: onCancel,
|
|
451
|
+
reply: reply
|
|
452
|
+
}),
|
|
453
|
+
collaborationContextValue: createCollaborationContext({ editReply: editReply, clearCommentState: clearCommentState })
|
|
454
|
+
}).user;
|
|
455
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Edit' }))];
|
|
456
|
+
case 1:
|
|
457
|
+
_a.sent();
|
|
415
458
|
expect(editReply).toHaveBeenCalledWith({
|
|
416
459
|
content: reply.content,
|
|
417
460
|
namedUsers: reply.namedUsers,
|
|
418
461
|
commentId: 'commentId',
|
|
419
462
|
replyId: reply.replyId
|
|
420
463
|
});
|
|
421
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
422
|
-
return __generator(this, function (_a) {
|
|
423
|
-
component.update();
|
|
424
|
-
return [2 /*return*/];
|
|
425
|
-
});
|
|
426
|
-
}); })];
|
|
427
|
-
case 1:
|
|
428
|
-
_a.sent();
|
|
429
464
|
expect(clearCommentState).toHaveBeenCalledWith('uri', 'comment/commentId/reply/replyId');
|
|
430
465
|
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
431
466
|
return [2 /*return*/];
|
|
@@ -433,30 +468,28 @@ describe('SendMessageArea tests', function () {
|
|
|
433
468
|
});
|
|
434
469
|
}); });
|
|
435
470
|
it('if received error after send request, do not need to clear text input', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
436
|
-
var editCommentWithReject, getCommentState, onCancel,
|
|
471
|
+
var editCommentWithReject, clearCommentState, getCommentState, onCancel, user;
|
|
437
472
|
return __generator(this, function (_a) {
|
|
438
473
|
switch (_a.label) {
|
|
439
474
|
case 0:
|
|
440
475
|
editCommentWithReject = jest.fn().mockRejectedValue('error');
|
|
476
|
+
clearCommentState = jest.fn();
|
|
441
477
|
getCommentState = jest.fn().mockImplementation(function () { return ({
|
|
442
478
|
value: 'Hello @[+vyacheslav](vyacheslav)',
|
|
443
479
|
plainTextValue: 'Hello +vyacheslav',
|
|
444
480
|
mentions: ['vyacheslav']
|
|
445
481
|
}); });
|
|
446
|
-
mockCollaborationContext({ sending: false, editComment: editCommentWithReject, getCommentState: getCommentState });
|
|
447
482
|
onCancel = jest.fn();
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
});
|
|
459
|
-
}); })];
|
|
483
|
+
user = setUp({
|
|
484
|
+
props: createProps(createCommentObject(), { isEditingComment: true, onCancel: onCancel }),
|
|
485
|
+
collaborationContextValue: createCollaborationContext({
|
|
486
|
+
sending: false,
|
|
487
|
+
editComment: editCommentWithReject,
|
|
488
|
+
getCommentState: getCommentState,
|
|
489
|
+
clearCommentState: clearCommentState
|
|
490
|
+
})
|
|
491
|
+
}).user;
|
|
492
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Edit' }))];
|
|
460
493
|
case 1:
|
|
461
494
|
_a.sent();
|
|
462
495
|
expect(clearCommentState).not.toHaveBeenCalled();
|
|
@@ -465,13 +498,21 @@ describe('SendMessageArea tests', function () {
|
|
|
465
498
|
}
|
|
466
499
|
});
|
|
467
500
|
}); });
|
|
468
|
-
it('should call onCancel if click cancel button', function () {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
501
|
+
it('should call onCancel if click cancel button', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
502
|
+
var onCancel, user;
|
|
503
|
+
return __generator(this, function (_a) {
|
|
504
|
+
switch (_a.label) {
|
|
505
|
+
case 0:
|
|
506
|
+
onCancel = jest.fn();
|
|
507
|
+
user = setUp({
|
|
508
|
+
props: createProps(createCommentObject(), { isEditingComment: true, onCancel: onCancel })
|
|
509
|
+
}).user;
|
|
510
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button', { name: 'Cancel' }))];
|
|
511
|
+
case 1:
|
|
512
|
+
_a.sent();
|
|
513
|
+
expect(onCancel).toHaveBeenCalledTimes(1);
|
|
514
|
+
return [2 /*return*/];
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}); });
|
|
477
518
|
});
|