@reltio/components 1.4.2069 → 1.4.2071
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/FacetViewHeader/FacetViewHeader.js +1 -1
- package/ImageAttributesLine/imageAttributeValues.test-data.js +8 -0
- package/ImageAttributesLine/index.d.ts +1 -1
- package/ImageAttributesLine/index.js +1 -1
- package/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +1 -1
- package/MergeButton/MergeButton.spec.js +55 -124
- package/MetadataTypesSelector/MetadataTypesSelector.js +1 -1
- package/MetadataTypesSelector/MetadataTypesSelector.test.js +193 -190
- package/MoreAttributesButton/MoreAttributesButton.test.js +173 -166
- package/MultiValueSelector/MultiValueSelector.test.js +78 -38
- package/MultipliableSelect/MultipliableSelect.test.js +111 -47
- package/NestedAttribute/NestedAttribute.test.js +121 -42
- package/NestedAttributeEditor/NestedAttributeEditor.test.js +95 -41
- package/NotMatchButton/NotMatchButton.spec.js +51 -100
- package/PieChart/PieChart.test.js +130 -114
- package/PinButton/PinButton.spec.js +89 -22
- package/PivotingTooltip/PivotingTooltip.test.js +338 -174
- package/PotentialMatchReviewCard/PotentialMatchReviewCard.spec.js +94 -29
- package/ProfileBand/ProfileBand.spec.js +60 -53
- package/ProfileCard/ProfileCard.test.js +109 -27
- package/ProfilesList/ProfilesList.d.ts +1 -3
- package/ProfilesList/ProfilesList.js +1 -1
- package/ProfilesList/ProfilesList.spec.js +226 -211
- package/QueryBuilderRow/QueryBuilderRow.spec.js +83 -90
- package/QueryBuilderRowsGroup/QueryBuilderRowsGroup.spec.js +195 -86
- package/ReactSelectLoadMoreButton/ReactSelectLoadMoreButton.test.js +73 -15
- package/ReactSelectMenuWithPopper/ReactSelectMenuWithPopper.test.js +71 -117
- package/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.test.js +128 -61
- package/ReadOnlyAttributesFactory/components/ReadOnlyAttribute/ReadOnlyAttribute.test.js +179 -44
- package/ReadOnlyAttributesList/ReadOnlyAttributesList.test.js +254 -211
- package/ReadOnlyAttributesList/attributes.test-data.js +4 -4
- package/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +75 -18
- package/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +187 -312
- package/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +210 -219
- package/ReadOnlyImageAttributesLine/ReadOnlyImageAttributesLine.test.js +89 -89
- package/ReferenceAttributeEditor/ReferenceAttributeEditor.test.js +556 -602
- package/ReferenceAttributeEditor/metadata.test-data.d.ts +13 -13
- package/ReferenceAttributeEditor/metadata.test-data.js +2 -2
- package/ReferenceAttributeEditor/styles.d.ts +1 -1
- package/RelationEditor/RelationEditor.test.js +1448 -1392
- package/RelationTypeSelector/RelationTypeSelector.test.js +99 -17
- package/RelationTypesSelector/RelationTypesSelector.test.js +73 -22
- package/ReltioMap/ReltioMap.spec.js +51 -25
- package/Roles/Roles.test.js +54 -10
- package/ScreenProfileBand/ScreenProfileBand.test.js +142 -72
- package/cjs/FacetViewHeader/FacetViewHeader.js +1 -1
- package/cjs/ImageAttributesLine/imageAttributeValues.test-data.js +8 -0
- package/cjs/ImageAttributesLine/index.d.ts +1 -1
- package/cjs/ImageAttributesLine/index.js +2 -1
- package/cjs/ImageDetailsView/components/ImageDetailsViewCarousel/ImageDetailsViewCarousel.js +1 -1
- package/cjs/MergeButton/MergeButton.spec.js +55 -124
- package/cjs/MetadataTypesSelector/MetadataTypesSelector.js +1 -1
- package/cjs/MetadataTypesSelector/MetadataTypesSelector.test.js +193 -190
- package/cjs/MoreAttributesButton/MoreAttributesButton.test.js +172 -165
- package/cjs/MultiValueSelector/MultiValueSelector.test.js +78 -38
- package/cjs/MultipliableSelect/MultipliableSelect.test.js +111 -47
- package/cjs/NestedAttribute/NestedAttribute.test.js +121 -42
- package/cjs/NestedAttributeEditor/NestedAttributeEditor.test.js +94 -40
- package/cjs/NotMatchButton/NotMatchButton.spec.js +51 -100
- package/cjs/PieChart/PieChart.test.js +130 -114
- package/cjs/PinButton/PinButton.spec.js +89 -22
- package/cjs/PivotingTooltip/PivotingTooltip.test.js +338 -174
- package/cjs/PotentialMatchReviewCard/PotentialMatchReviewCard.spec.js +94 -29
- package/cjs/ProfileBand/ProfileBand.spec.js +60 -53
- package/cjs/ProfileCard/ProfileCard.test.js +109 -27
- package/cjs/ProfilesList/ProfilesList.d.ts +1 -3
- package/cjs/ProfilesList/ProfilesList.js +1 -1
- package/cjs/ProfilesList/ProfilesList.spec.js +226 -211
- package/cjs/QueryBuilderRow/QueryBuilderRow.spec.js +83 -90
- package/cjs/QueryBuilderRowsGroup/QueryBuilderRowsGroup.spec.js +195 -86
- package/cjs/ReactSelectLoadMoreButton/ReactSelectLoadMoreButton.test.js +73 -15
- package/cjs/ReactSelectMenuWithPopper/ReactSelectMenuWithPopper.test.js +71 -117
- package/cjs/ReadOnlyAttributeValuesBlock/ReadOnlyAttributeValuesBlock.test.js +128 -61
- package/cjs/ReadOnlyAttributesFactory/components/ReadOnlyAttribute/ReadOnlyAttribute.test.js +179 -44
- package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.test.js +254 -211
- package/cjs/ReadOnlyAttributesList/attributes.test-data.js +4 -4
- package/cjs/ReadOnlyAttributesPager/ReadOnlyAttributesPager.test.js +75 -18
- package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +185 -310
- package/cjs/ReadOnlyComplexAttribute/ReadOnlyComplexAttribute.test.js +209 -218
- package/cjs/ReadOnlyImageAttributesLine/ReadOnlyImageAttributesLine.test.js +89 -89
- package/cjs/ReferenceAttributeEditor/ReferenceAttributeEditor.test.js +555 -601
- package/cjs/ReferenceAttributeEditor/metadata.test-data.d.ts +13 -13
- package/cjs/ReferenceAttributeEditor/metadata.test-data.js +2 -2
- package/cjs/ReferenceAttributeEditor/styles.d.ts +1 -1
- package/cjs/RelationEditor/RelationEditor.test.js +1446 -1390
- package/cjs/RelationTypeSelector/RelationTypeSelector.test.js +99 -17
- package/cjs/RelationTypesSelector/RelationTypesSelector.test.js +73 -22
- package/cjs/ReltioMap/ReltioMap.spec.js +51 -25
- package/cjs/Roles/Roles.test.js +54 -10
- package/cjs/ScreenProfileBand/ScreenProfileBand.test.js +141 -71
- package/package.json +2 -2
- package/MetadataTypesSelector/components/ListLabel/ListLabel.test.d.ts +0 -1
- package/MetadataTypesSelector/components/ListLabel/ListLabel.test.js +0 -24
- package/PivotingTooltip/IntegrationPivotingTooltip.test.d.ts +0 -1
- package/PivotingTooltip/IntegrationPivotingTooltip.test.js +0 -356
- package/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.d.ts +0 -1
- package/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.js +0 -201
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.d.ts +0 -1
- package/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.js +0 -43
- package/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.d.ts +0 -1
- package/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.js +0 -31
- package/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.d.ts +0 -1
- package/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.js +0 -31
- package/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -45
- package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.js +0 -114
- package/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.js +0 -107
- package/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
- package/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -72
- package/RelationEditor/IntegrationRelationEditor.test.d.ts +0 -1
- package/RelationEditor/IntegrationRelationEditor.test.js +0 -337
- package/ReltioMap/components/MapControlContainer/MapControlContainer.d.ts +0 -10
- package/ReltioMap/components/MapControlContainer/MapControlContainer.js +0 -24
- package/ReltioMap/components/MapControlContainer/MapControlContainer.spec.d.ts +0 -1
- package/ReltioMap/components/MapControlContainer/MapControlContainer.spec.js +0 -33
- package/ReltioMap/components/MapControlContainer/index.d.ts +0 -1
- package/ReltioMap/components/MapControlContainer/index.js +0 -1
- package/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.d.ts +0 -1
- package/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.js +0 -36
- package/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.d.ts +0 -1
- package/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.js +0 -60
- package/Roles/components/Role/Role.test.d.ts +0 -1
- package/Roles/components/Role/Role.test.js +0 -55
- package/cjs/MetadataTypesSelector/components/ListLabel/ListLabel.test.d.ts +0 -1
- package/cjs/MetadataTypesSelector/components/ListLabel/ListLabel.test.js +0 -52
- package/cjs/PivotingTooltip/IntegrationPivotingTooltip.test.d.ts +0 -1
- package/cjs/PivotingTooltip/IntegrationPivotingTooltip.test.js +0 -361
- package/cjs/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.d.ts +0 -1
- package/cjs/PivotingTooltip/components/PivotingTooltipContent/PivotingTooltipContent.test.js +0 -206
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.d.ts +0 -1
- package/cjs/ProfileCard/components/ProfileCardContent/ProfileCardContent.test.js +0 -48
- package/cjs/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.d.ts +0 -1
- package/cjs/QueryBuilderRow/components/ReadOnlyFilter/ReadOnlyFilter.spec.js +0 -36
- package/cjs/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.d.ts +0 -1
- package/cjs/QueryBuilderRow/components/ReadOnlyLogicOperator/ReadOnlyLogicOperator.spec.js +0 -36
- package/cjs/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/ImageLineRenderer/ImageLineRenderer.test.js +0 -50
- package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/MultiLineRenderer/MultiLineRenderer.test.js +0 -119
- package/cjs/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/OneLineRenderer/OneLineRenderer.test.js +0 -112
- package/cjs/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.d.ts +0 -1
- package/cjs/ReadOnlyAttributesPager/components/SpecialRenderer/SpecialRenderer.test.js +0 -77
- package/cjs/RelationEditor/IntegrationRelationEditor.test.d.ts +0 -1
- package/cjs/RelationEditor/IntegrationRelationEditor.test.js +0 -342
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.d.ts +0 -10
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.js +0 -28
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.spec.d.ts +0 -1
- package/cjs/ReltioMap/components/MapControlContainer/MapControlContainer.spec.js +0 -38
- package/cjs/ReltioMap/components/MapControlContainer/index.d.ts +0 -1
- package/cjs/ReltioMap/components/MapControlContainer/index.js +0 -5
- package/cjs/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.d.ts +0 -1
- package/cjs/ReltioMap/components/TopCenterMapControls/TopCenterMapControls.spec.js +0 -41
- package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.d.ts +0 -1
- package/cjs/ReltioMap/components/TopRightMapControls/TopRightMapControls.spec.js +0 -65
- package/cjs/Roles/components/Role/Role.test.d.ts +0 -1
- package/cjs/Roles/components/Role/Role.test.js +0 -60
|
@@ -51,106 +51,77 @@ 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
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
56
56
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
57
57
|
var NotMatchButton_1 = require("./NotMatchButton");
|
|
58
|
-
var ActionButton_1 = require("../ActionButton");
|
|
59
58
|
var types_1 = require("../types");
|
|
60
|
-
var NotMatchDark_1 = __importDefault(require("../icons/NotMatchDark"));
|
|
61
59
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
62
60
|
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { markMixedEntitiesAsNotMatches: jest.fn(), markDataTenantEntityAsNotMatch: jest.fn() })); });
|
|
63
|
-
var mdmValues = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
61
|
+
var mdmValues = { tenant: { id: 'test', name: 'test' }, dtssPath: 'dtssPath/' };
|
|
62
|
+
var defaultEntity = { uri: 'entities/123', type: 'entityType' };
|
|
63
|
+
var defaultEntities = [
|
|
64
|
+
{ uri: 'entities/345', type: 'entityType' },
|
|
65
|
+
{ uri: 'entities/678', type: 'entityType' }
|
|
66
|
+
];
|
|
67
|
+
var defaultProps = { entity: defaultEntity, entities: defaultEntities };
|
|
70
68
|
var setUp = function (props) {
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
if (props === void 0) { props = defaultProps; }
|
|
70
|
+
var user = user_event_1.default.setup();
|
|
71
|
+
var Providers = function (_a) {
|
|
72
|
+
var children = _a.children;
|
|
73
|
+
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues }, children));
|
|
74
|
+
};
|
|
75
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(NotMatchButton_1.NotMatchButton, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
73
76
|
};
|
|
74
|
-
describe('
|
|
77
|
+
describe('Not match button tests', function () {
|
|
75
78
|
beforeEach(function () {
|
|
79
|
+
mdm_sdk_1.markMixedEntitiesAsNotMatches.mockResolvedValue({ status: 'success' });
|
|
80
|
+
mdm_sdk_1.markDataTenantEntityAsNotMatch.mockResolvedValue({ status: 'success' });
|
|
81
|
+
});
|
|
82
|
+
afterEach(function () {
|
|
76
83
|
jest.clearAllMocks();
|
|
77
|
-
mdm_sdk_1.markMixedEntitiesAsNotMatches.mockImplementation(function () { return Promise.resolve({ status: 'success' }); });
|
|
78
|
-
mdm_sdk_1.markDataTenantEntityAsNotMatch.mockImplementation(function () { return Promise.resolve({ status: 'success' }); });
|
|
79
84
|
});
|
|
80
|
-
var entity = { uri: 'entities/123', type: 'entityType' };
|
|
81
|
-
var entities = [
|
|
82
|
-
{
|
|
83
|
-
uri: 'entities/345',
|
|
84
|
-
type: 'entityType'
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
uri: 'entities/678',
|
|
88
|
-
type: 'entityType'
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
85
|
it('should render initial state correctly', function () {
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
var button =
|
|
95
|
-
expect(button).
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
label: 'Not a match',
|
|
99
|
-
icon: NotMatchDark_1.default,
|
|
100
|
-
mode: mode
|
|
101
|
-
});
|
|
86
|
+
var props = __assign(__assign({}, defaultProps), { mode: types_1.ActionButtonMode.button });
|
|
87
|
+
setUp(props);
|
|
88
|
+
var button = react_2.screen.getByRole('button');
|
|
89
|
+
expect(button).not.toBeDisabled();
|
|
90
|
+
(0, react_2.within)(button).getByTestId('SvgNotMatchDark');
|
|
91
|
+
(0, react_2.within)(button).getByText('Not a match');
|
|
102
92
|
});
|
|
103
93
|
it('should mark entities as not match to customer tenant entity on button click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
104
|
-
var
|
|
94
|
+
var user;
|
|
105
95
|
return __generator(this, function (_a) {
|
|
106
96
|
switch (_a.label) {
|
|
107
97
|
case 0:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(button).toHaveLength(1);
|
|
111
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
-
return __generator(this, function (_a) {
|
|
113
|
-
button.prop('onClick')();
|
|
114
|
-
return [2 /*return*/];
|
|
115
|
-
});
|
|
116
|
-
}); })];
|
|
98
|
+
user = setUp().user;
|
|
99
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button'))];
|
|
117
100
|
case 1:
|
|
118
101
|
_a.sent();
|
|
119
102
|
expect(mdm_sdk_1.markMixedEntitiesAsNotMatches).toHaveBeenCalledWith({
|
|
120
|
-
dtssPath: 'dtssPath/',
|
|
121
103
|
customerTenant: 'test',
|
|
122
|
-
|
|
123
|
-
entities:
|
|
104
|
+
dtssPath: 'dtssPath/',
|
|
105
|
+
entities: defaultEntities,
|
|
106
|
+
entity: defaultEntity
|
|
124
107
|
});
|
|
125
108
|
return [2 /*return*/];
|
|
126
109
|
}
|
|
127
110
|
});
|
|
128
111
|
}); });
|
|
129
112
|
it('should mark entities as not match to data tenant entity on button click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
130
|
-
var entity, entities,
|
|
113
|
+
var entity, entities, props, user;
|
|
131
114
|
return __generator(this, function (_a) {
|
|
132
115
|
switch (_a.label) {
|
|
133
116
|
case 0:
|
|
134
|
-
entity = { uri: 'entities/dt123',
|
|
117
|
+
entity = { uri: 'entities/dt123', type: 'entityType', dataTenant: 'dt1' };
|
|
135
118
|
entities = [
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
type: 'entityType'
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
uri: 'entities/ct678',
|
|
142
|
-
type: 'entityType'
|
|
143
|
-
}
|
|
119
|
+
{ uri: 'entities/ct345', type: 'entityType' },
|
|
120
|
+
{ uri: 'entities/ct678', type: 'entityType' }
|
|
144
121
|
];
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
-
return __generator(this, function (_a) {
|
|
150
|
-
button.prop('onClick')();
|
|
151
|
-
return [2 /*return*/];
|
|
152
|
-
});
|
|
153
|
-
}); })];
|
|
122
|
+
props = { entity: entity, entities: entities };
|
|
123
|
+
user = setUp(props).user;
|
|
124
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button'))];
|
|
154
125
|
case 1:
|
|
155
126
|
_a.sent();
|
|
156
127
|
expect(mdm_sdk_1.markDataTenantEntityAsNotMatch).toHaveBeenCalledWith({
|
|
@@ -164,54 +135,34 @@ describe('NotMatchButton component test', function () {
|
|
|
164
135
|
});
|
|
165
136
|
}); });
|
|
166
137
|
it('should call props.onSuccess if request is successful', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
167
|
-
var
|
|
138
|
+
var props, user;
|
|
168
139
|
return __generator(this, function (_a) {
|
|
169
140
|
switch (_a.label) {
|
|
170
141
|
case 0:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
expect(button).toHaveLength(1);
|
|
175
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
176
|
-
return __generator(this, function (_a) {
|
|
177
|
-
button.prop('onClick')();
|
|
178
|
-
return [2 /*return*/];
|
|
179
|
-
});
|
|
180
|
-
}); })];
|
|
142
|
+
props = __assign(__assign({}, defaultProps), { onSuccess: jest.fn() });
|
|
143
|
+
user = setUp(props).user;
|
|
144
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button'))];
|
|
181
145
|
case 1:
|
|
182
146
|
_a.sent();
|
|
183
|
-
expect(onSuccess).toHaveBeenCalled();
|
|
147
|
+
expect(props.onSuccess).toHaveBeenCalled();
|
|
184
148
|
return [2 /*return*/];
|
|
185
149
|
}
|
|
186
150
|
});
|
|
187
151
|
}); });
|
|
188
152
|
it('should call props.onError on not match error', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
189
|
-
var
|
|
153
|
+
var props, user;
|
|
190
154
|
return __generator(this, function (_a) {
|
|
191
155
|
switch (_a.label) {
|
|
192
156
|
case 0:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
button = wrapper.find(ActionButton_1.ActionButton);
|
|
198
|
-
expect(button).toHaveLength(1);
|
|
199
|
-
return [4 /*yield*/, (0, test_utils_1.act)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
200
|
-
return __generator(this, function (_a) {
|
|
201
|
-
button.prop('onClick')();
|
|
202
|
-
return [2 /*return*/];
|
|
203
|
-
});
|
|
204
|
-
}); })];
|
|
157
|
+
mdm_sdk_1.markMixedEntitiesAsNotMatches.mockRejectedValue({ errorMessage: 'not match failed' });
|
|
158
|
+
props = __assign(__assign({}, defaultProps), { onError: jest.fn() });
|
|
159
|
+
user = setUp(props).user;
|
|
160
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button'))];
|
|
205
161
|
case 1:
|
|
206
162
|
_a.sent();
|
|
207
|
-
expect(onError).toHaveBeenCalledWith(
|
|
163
|
+
expect(props.onError).toHaveBeenCalledWith({ errorMessage: 'not match failed' });
|
|
208
164
|
return [2 /*return*/];
|
|
209
165
|
}
|
|
210
166
|
});
|
|
211
167
|
}); });
|
|
212
|
-
it('button should have right label', function () {
|
|
213
|
-
var wrapper = setUp({ entity: entity, entities: entities });
|
|
214
|
-
var button = wrapper.find(ActionButton_1.ActionButton);
|
|
215
|
-
expect(button.prop('label')).toBe('Not a match');
|
|
216
|
-
});
|
|
217
168
|
});
|
|
@@ -22,131 +22,147 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
36
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
25
61
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
62
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
63
|
};
|
|
28
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
65
|
var react_1 = __importDefault(require("react"));
|
|
30
|
-
var
|
|
31
|
-
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
66
|
+
var react_2 = require("@testing-library/react");
|
|
32
67
|
var PieChart_1 = __importStar(require("./PieChart"));
|
|
33
|
-
|
|
34
|
-
var ActiveShape_1 = require("./components/ActiveShape");
|
|
35
|
-
describe('PieChart', function () {
|
|
68
|
+
describe('Pie chart tests', function () {
|
|
36
69
|
var data = [
|
|
37
70
|
{ label: 'first', value: 1, percent: 1, group: '1' },
|
|
38
71
|
{ label: 'second', value: 2, percent: 2, group: '2' },
|
|
39
72
|
{ label: 'third', value: 3, percent: 3, group: '3' }
|
|
40
73
|
];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
expect(wrapper.find(recharts_1.PieChart)).toHaveLength(1);
|
|
64
|
-
expect(wrapper.find(recharts_1.Pie)).toHaveLength(1);
|
|
65
|
-
expect(wrapper.find(recharts_1.Cell)).toHaveLength(3);
|
|
66
|
-
expect(wrapper.find(recharts_1.Legend)).toHaveLength(1);
|
|
67
|
-
var cells = wrapper.find(recharts_1.Cell);
|
|
68
|
-
expect(cells).toHaveLength(3);
|
|
69
|
-
cells.forEach(function (item, index) {
|
|
70
|
-
expect(item.prop('fill')).toBe((0, mdm_sdk_1.getChartItemColor)(data[index].label));
|
|
74
|
+
it('should render correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var container, chart, legend, legendItems, sectors;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
container = (0, react_2.render)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data })).container;
|
|
80
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(container.querySelector('.recharts-pie-sector')).toBeInTheDocument(); })];
|
|
81
|
+
case 1:
|
|
82
|
+
_a.sent();
|
|
83
|
+
chart = container.querySelector('.recharts-surface');
|
|
84
|
+
expect(chart).toHaveAttribute('width', '600');
|
|
85
|
+
expect(chart).toHaveAttribute('height', '300');
|
|
86
|
+
legend = container.querySelector('.recharts-legend-wrapper');
|
|
87
|
+
legendItems = legend.querySelectorAll('.item');
|
|
88
|
+
expect(legendItems).toHaveLength(3);
|
|
89
|
+
expect(legendItems[0]).toHaveTextContent('first (1%)');
|
|
90
|
+
expect(legendItems[1]).toHaveTextContent('second (2%)');
|
|
91
|
+
expect(legendItems[2]).toHaveTextContent('third (3%)');
|
|
92
|
+
sectors = container.querySelectorAll('.recharts-pie-sector');
|
|
93
|
+
expect(sectors).toHaveLength(3);
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
}
|
|
71
96
|
});
|
|
72
|
-
});
|
|
73
|
-
it('should render
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var wrapper = (0, enzyme_1.shallow)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data }));
|
|
85
|
-
expect(wrapper.find(recharts_1.PieChart)).toHaveLength(1);
|
|
86
|
-
expect(wrapper.find(recharts_1.Tooltip)).toHaveLength(1);
|
|
87
|
-
var pie = wrapper.find(recharts_1.Pie);
|
|
88
|
-
expect(pie).toHaveLength(1);
|
|
89
|
-
expect(pie.prop('activeShape')).toBe(undefined);
|
|
90
|
-
expect(pie.prop('onMouseEnter')).toBe(undefined);
|
|
91
|
-
expect(pie.prop('onMouseLeave')).toBe(undefined);
|
|
92
|
-
expect(pie.prop('outerRadius')).toBe('80%');
|
|
93
|
-
var options = {
|
|
94
|
-
showActiveShape: true
|
|
95
|
-
};
|
|
96
|
-
wrapper.setProps({ options: options });
|
|
97
|
-
var updatedPie = wrapper.find(recharts_1.Pie);
|
|
98
|
-
expect(updatedPie).toHaveLength(1);
|
|
99
|
-
expect(wrapper.find(recharts_1.Tooltip)).toHaveLength(0);
|
|
100
|
-
expect(updatedPie.prop('activeShape')).toBe(ActiveShape_1.ActiveShape);
|
|
101
|
-
expect(updatedPie.prop('onMouseEnter')).not.toBe(undefined);
|
|
102
|
-
expect(updatedPie.prop('onMouseLeave')).not.toBe(undefined);
|
|
103
|
-
expect(updatedPie.prop('outerRadius')).toBe('70%');
|
|
104
|
-
});
|
|
105
|
-
it('should render donut chart or pie chart depending on props.isDonut', function () {
|
|
106
|
-
var wrapper = (0, enzyme_1.shallow)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data }));
|
|
107
|
-
expect(wrapper.find(recharts_1.Pie).prop('innerRadius')).toBe(0);
|
|
108
|
-
wrapper.setProps({ isDonut: true });
|
|
109
|
-
expect(wrapper.find(recharts_1.Pie).prop('innerRadius')).toBe('60%');
|
|
110
|
-
var options = {
|
|
111
|
-
showActiveShape: true
|
|
112
|
-
};
|
|
113
|
-
wrapper.setProps({ options: options });
|
|
114
|
-
expect(wrapper.find(recharts_1.Pie).prop('innerRadius')).toBe('50%');
|
|
115
|
-
});
|
|
116
|
-
it('should call props.onItemClick on sector click', function () {
|
|
117
|
-
jest.useFakeTimers();
|
|
118
|
-
var onItemClick = jest.fn();
|
|
119
|
-
var wrapper = (0, enzyme_1.mount)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data, onItemClick: onItemClick }));
|
|
120
|
-
jest.runAllTimers();
|
|
121
|
-
wrapper.update();
|
|
122
|
-
var sector = wrapper.find('.recharts-pie-sector').first();
|
|
123
|
-
sector.simulate('click');
|
|
124
|
-
expect(onItemClick).toHaveBeenCalledWith('1');
|
|
125
|
-
jest.useRealTimers();
|
|
126
|
-
});
|
|
127
|
-
it('should render chart legend with percents correctly', function () {
|
|
128
|
-
var legendPayload = [
|
|
129
|
-
{
|
|
130
|
-
id: 'first',
|
|
131
|
-
type: 'square',
|
|
132
|
-
color: (0, mdm_sdk_1.getChartItemColor)('first'),
|
|
133
|
-
value: 'first (16.7%)'
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
id: 'second',
|
|
137
|
-
type: 'square',
|
|
138
|
-
color: (0, mdm_sdk_1.getChartItemColor)('second'),
|
|
139
|
-
value: 'second (33.3%)'
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
id: 'third',
|
|
143
|
-
type: 'square',
|
|
144
|
-
color: (0, mdm_sdk_1.getChartItemColor)('third'),
|
|
145
|
-
value: 'third (50%)'
|
|
97
|
+
}); });
|
|
98
|
+
it('should not render legend if showLegend prop is false', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
99
|
+
var container;
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
container = (0, react_2.render)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data, options: { showLegend: false } })).container;
|
|
104
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(container.querySelector('.recharts-pie-sector')).toBeInTheDocument(); })];
|
|
105
|
+
case 1:
|
|
106
|
+
_a.sent();
|
|
107
|
+
expect(container.querySelector('.recharts-legend-wrapper')).not.toBeInTheDocument();
|
|
108
|
+
return [2 /*return*/];
|
|
146
109
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
110
|
+
});
|
|
111
|
+
}); });
|
|
112
|
+
it('should handle hover correctly if showActiveShape is true', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
|
+
var container, tooltip;
|
|
114
|
+
return __generator(this, function (_a) {
|
|
115
|
+
switch (_a.label) {
|
|
116
|
+
case 0:
|
|
117
|
+
container = (0, react_2.render)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data, isDonut: true })).container;
|
|
118
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(container.querySelector('.recharts-pie-sector')).toBeInTheDocument(); })];
|
|
119
|
+
case 1:
|
|
120
|
+
_a.sent();
|
|
121
|
+
// eslint-disable-next-line testing-library/prefer-user-event
|
|
122
|
+
react_2.fireEvent.mouseEnter(container.querySelector('.recharts-pie-sector'));
|
|
123
|
+
tooltip = react_2.screen.getByTestId('chart-tooltip');
|
|
124
|
+
expect(tooltip).toHaveTextContent('first1 (1%)');
|
|
125
|
+
// eslint-disable-next-line testing-library/prefer-user-event
|
|
126
|
+
react_2.fireEvent.mouseLeave(container.querySelector('.recharts-pie-sector'));
|
|
127
|
+
expect(tooltip).not.toBeInTheDocument();
|
|
128
|
+
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}); });
|
|
132
|
+
it('should call props.onItemClick on sector click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
133
|
+
var onItemClick, container;
|
|
134
|
+
return __generator(this, function (_a) {
|
|
135
|
+
switch (_a.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
onItemClick = jest.fn();
|
|
138
|
+
container = (0, react_2.render)(react_1.default.createElement(PieChart_1.PieChart, { width: 600, height: 300, data: data, onItemClick: onItemClick })).container;
|
|
139
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(container.querySelector('.recharts-pie-sector')).toBeInTheDocument(); })];
|
|
140
|
+
case 1:
|
|
141
|
+
_a.sent();
|
|
142
|
+
// eslint-disable-next-line testing-library/prefer-user-event
|
|
143
|
+
react_2.fireEvent.click(container.querySelector('.recharts-pie-sector'));
|
|
144
|
+
expect(onItemClick).toHaveBeenCalledWith('1');
|
|
145
|
+
return [2 /*return*/];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}); });
|
|
149
|
+
it('should render chart legend with percents correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
150
|
+
var container, legend, legendItems;
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
switch (_a.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
container = (0, react_2.render)(react_1.default.createElement(PieChart_1.default, { width: 600, height: 300, data: data })).container;
|
|
155
|
+
return [4 /*yield*/, (0, react_2.waitFor)(function () { return expect(container.querySelector('.recharts-pie-sector')).toBeInTheDocument(); })];
|
|
156
|
+
case 1:
|
|
157
|
+
_a.sent();
|
|
158
|
+
legend = container.querySelector('.recharts-legend-wrapper');
|
|
159
|
+
legendItems = legend.querySelectorAll('.item');
|
|
160
|
+
expect(legendItems).toHaveLength(3);
|
|
161
|
+
expect(legendItems[0]).toHaveTextContent('first (16.7%)');
|
|
162
|
+
expect(legendItems[1]).toHaveTextContent('second (33.3%)');
|
|
163
|
+
expect(legendItems[2]).toHaveTextContent('third (50%)');
|
|
164
|
+
return [2 /*return*/];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}); });
|
|
152
168
|
});
|
|
@@ -1,34 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
2
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
51
|
};
|
|
5
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
53
|
var react_1 = __importDefault(require("react"));
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var PinOutlined_1 = __importDefault(require("../icons/PinOutlined"));
|
|
10
|
-
var SmallIconButton_1 = require("../SmallIconButton");
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
11
56
|
var PinButton_1 = require("./PinButton");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
57
|
+
var defaultProps = { isPinned: false, onClick: jest.fn() };
|
|
58
|
+
var setUp = function (props) {
|
|
59
|
+
if (props === void 0) { props = defaultProps; }
|
|
60
|
+
var user = user_event_1.default.setup();
|
|
61
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(PinButton_1.PinButton, __assign({}, props)))), { user: user });
|
|
62
|
+
};
|
|
63
|
+
describe('Pin button tests', function () {
|
|
64
|
+
afterEach(function () {
|
|
65
|
+
jest.clearAllMocks();
|
|
18
66
|
});
|
|
19
|
-
it('should
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
expect(
|
|
67
|
+
it('should render correctly in basic case', function () {
|
|
68
|
+
setUp();
|
|
69
|
+
react_2.screen.getByLabelText('Pin');
|
|
70
|
+
expect(react_2.screen.getByRole('button')).not.toBeDisabled();
|
|
71
|
+
react_2.screen.getByTestId('SvgPinOutlined');
|
|
23
72
|
});
|
|
24
|
-
it('should
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
73
|
+
it('should render correctly if disabled prop is true', function () {
|
|
74
|
+
var props = __assign(__assign({}, defaultProps), { disabled: true });
|
|
75
|
+
setUp(props);
|
|
76
|
+
react_2.screen.getByLabelText("You don't have permissions to pin");
|
|
77
|
+
expect(react_2.screen.getByRole('button')).toBeDisabled();
|
|
78
|
+
react_2.screen.getByTestId('SvgPinOutlined');
|
|
28
79
|
});
|
|
29
|
-
it('should
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
80
|
+
it('should render correctly if isPinned prop is true', function () {
|
|
81
|
+
var props = __assign(__assign({}, defaultProps), { isPinned: true });
|
|
82
|
+
setUp(props);
|
|
83
|
+
react_2.screen.getByLabelText('Pin');
|
|
84
|
+
expect(react_2.screen.getByRole('button')).not.toBeDisabled();
|
|
85
|
+
react_2.screen.getByTestId('SvgPin');
|
|
33
86
|
});
|
|
87
|
+
it('should call onClick handler on button click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
var user;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
user = setUp().user;
|
|
93
|
+
return [4 /*yield*/, user.click(react_2.screen.getByRole('button'))];
|
|
94
|
+
case 1:
|
|
95
|
+
_a.sent();
|
|
96
|
+
expect(defaultProps.onClick).toHaveBeenCalled();
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); });
|
|
34
101
|
});
|