@licklist/design 0.63.3 → 0.65.0-dev.0
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/bitbucket-pipelines.yml +0 -8
- package/dist/date-time-button/DateTimeButton.js +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
- package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
- package/dist/iframe/ryft/RyftPaymentForm.d.ts +4 -1
- package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
- package/dist/iframe/ryft/RyftPaymentForm.js +1 -1
- package/dist/iframe/ryft/utils/ryft-form.d.ts +5 -2
- package/dist/iframe/ryft/utils/ryft-form.d.ts.map +1 -1
- package/dist/iframe/ryft/utils/ryft-form.js +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
- package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
- package/dist/product-set/control/DateInput.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts +3 -2
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/control/ProductSetControl.js +1 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts +3 -1
- package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductCategoriesControl.js +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts +6 -2
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/product-set/form/ProductsControl.d.ts +3 -1
- package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -1
- package/dist/product-set/form/StepsControl.d.ts +3 -1
- package/dist/product-set/form/StepsControl.d.ts.map +1 -1
- package/dist/product-set/form/StepsControl.js +1 -1
- package/dist/product-set/product/ProductControl.d.ts +1 -0
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/step/StepControl.d.ts +2 -1
- package/dist/product-set/step/StepControl.d.ts.map +1 -1
- package/dist/product-set/step/StepControl.js +1 -1
- package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
- package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +3 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
- package/dist/recurring-date-picker-input/utils.d.ts +5 -0
- package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
- package/dist/recurring-date-picker-input/utils.js +1 -1
- package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
- package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
- package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.d.ts +1 -2
- package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
- package/dist/sortable-tree/SortableTreeItem.js +1 -1
- package/dist/styles/date-time-button/DateTimeButton.scss +1 -0
- package/dist/styles/iframe-page/PageBody.scss +0 -1
- package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +8 -0
- package/dist/styles/sales/BookingResults.scss +1 -1
- package/dist/styles/zones/ZoneForm.scss +2 -1
- package/dist/zone/form/ZoneForm.d.ts +2 -2
- package/dist/zone/form/ZoneForm.d.ts.map +1 -1
- package/dist/zone/form/ZoneForm.js +1 -1
- package/dist/zone/form/components/ZoneControl.d.ts +2 -2
- package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneControl.js +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
- package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
- package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
- package/dist/zone/form/utils/dates.d.ts.map +1 -1
- package/package.json +14 -39
- package/src/date-time-button/DateTimeButton.stories.tsx +2 -1
- package/src/date-time-button/DateTimeButton.tsx +7 -5
- package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +14 -9
- package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +2 -0
- package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -0
- package/src/iframe/ryft/RyftPaymentForm.tsx +11 -2
- package/src/iframe/ryft/utils/ryft-form.ts +23 -4
- package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -4
- package/src/product-set/control/DateInput.tsx +2 -2
- package/src/product-set/control/ProductSetControl.tsx +17 -5
- package/src/product-set/form/ProductCategoriesControl.tsx +15 -4
- package/src/product-set/form/ProductSetForm.tsx +13 -2
- package/src/product-set/form/ProductsControl.tsx +93 -77
- package/src/product-set/form/StepsControl.tsx +15 -7
- package/src/product-set/product/ProductControl.tsx +8 -5
- package/src/product-set/step/StepControl.tsx +4 -3
- package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
- package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +40 -21
- package/src/recurring-date-picker-input/RecurringDatePickerInput.stories.tsx +13 -7
- package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +12 -1
- package/src/recurring-date-picker-input/utils.ts +90 -1
- package/src/sales/booking/results/components/ResultCard.tsx +0 -3
- package/src/setting/admin/AdminSettingForm.tsx +2 -2
- package/src/sortable-tree/SortableTreeItem.tsx +0 -3
- package/src/static/switch/BooleanSwitch.tsx +1 -1
- package/src/styles/date-time-button/DateTimeButton.scss +1 -0
- package/src/styles/iframe-page/PageBody.scss +0 -1
- package/src/styles/ryft-payment-form/RyftPaymentForm.scss +8 -0
- package/src/styles/sales/BookingResults.scss +1 -1
- package/src/styles/zones/ZoneForm.scss +2 -1
- package/src/zone/form/ZoneForm.tsx +3 -2
- package/src/zone/form/components/ZoneControl.tsx +3 -3
- package/src/zone/form/components/ZoneRecurrencesControl.tsx +7 -5
- package/src/zone/form/utils/dates.ts +9 -10
- package/jest.config.js +0 -29
- package/tests/Auth/Authorizer.test.tsx +0 -194
- package/tests/Auth/Layout/UserNavDropDown.test.tsx +0 -43
- package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +0 -33
- package/tests/Auth/Login/LoginComponent.test.tsx +0 -246
- package/tests/Auth/Login/LoginFormComponent.test.tsx +0 -182
- package/tests/Auth/Register/RegisterComponent.test.tsx +0 -285
- package/tests/Auth/Register/RegisterFormComponent.test.tsx +0 -170
- package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +0 -130
- package/tests/Auth/Social/SocialCallbackComponent.test.tsx +0 -133
- package/tests/Auth/Social/SocialFormComponent.test.tsx +0 -118
- package/tests/FileUpload/FileUpload.test.tsx +0 -42
- package/tests/Notification/EmailTemplate.test.tsx +0 -82
- package/tests/ProductSet/ProductSetPopover.test.tsx +0 -40
- package/tests/Report/Report.test.tsx +0 -48
- package/tests/Sales/Coupon.test.tsx +0 -51
- package/tests/Sales/SalesAndVIews.test.tsx +0 -63
- package/tests/SnippetTemplates/SnippetTemplates.test.tsx +0 -56
- package/tests/Table/FilterHelperComponent.test.tsx +0 -88
- package/tests/Table/PaginationHelperComponent.test.tsx +0 -109
- package/tests/Table/PerPageHelperComponent.test.tsx +0 -34
- package/tests/Table/TableHelperComponent.test.tsx +0 -295
- package/tests/TipTapEditor/TipTapEditor.test.tsx +0 -28
- package/tests/__mock__/hooks/useAuthApi.ts +0 -13
- package/tests/__mock__/hooks/useAuthMock.ts +0 -13
- package/tests/__mock__/hooks/useFormMock.ts +0 -27
- package/tests/__mock__/hooks/useNotificationMock.ts +0 -13
- package/tests/__mock__/hooks/useQueryMock.ts +0 -16
- package/tests/__mock__/hooks/useSocialApiMock.ts +0 -20
- package/tests/__mock__/hooks/useTranslationMock.ts +0 -17
- package/tests/__mock__/hooks/useUserApiMock.ts +0 -18
- package/tests/__mock__/hooks/useUserMock.ts +0 -13
- package/tests/__mock__/styleMock.js +0 -1
- package/tests/__mock__/windowMock.ts +0 -5
- package/tests/packages/react-query.tsx +0 -28
- package/tests/setupTests.ts +0 -10
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import TableService from "@licklist/plugins/dist/services/Table/TableService";
|
|
2
|
-
import ILengthAwarePaginator from "@licklist/plugins/dist/types/services/Table/ILengthAwarePaginator";
|
|
3
|
-
import ITableHeader from "@licklist/plugins/dist/types/services/Table/ITableHeader";
|
|
4
|
-
import { mount, shallow } from "enzyme";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { act } from "react-dom/test-utils";
|
|
7
|
-
import {
|
|
8
|
-
FilterHelperComponent,
|
|
9
|
-
PaginationHelperComponent,
|
|
10
|
-
PerPageHelperComponent,
|
|
11
|
-
TableHelperComponent,
|
|
12
|
-
} from "../../src/table";
|
|
13
|
-
import { getFilterOptionsValue } from "../../src/table/utils";
|
|
14
|
-
import useQueryMock from "../__mock__/hooks/useQueryMock";
|
|
15
|
-
|
|
16
|
-
jest.mock("@licklist/plugins/dist/hooks/Query/useQuery");
|
|
17
|
-
jest.mock("react-router-dom", () => ({
|
|
18
|
-
useLocation: () => ({
|
|
19
|
-
pathname: "/",
|
|
20
|
-
}),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
useQueryMock();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
afterAll(() => {
|
|
28
|
-
jest.resetAllMocks();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe("TableHelperComponent", () => {
|
|
32
|
-
const getPaginator = (): ILengthAwarePaginator<any> => ({
|
|
33
|
-
current_page: 1,
|
|
34
|
-
last_page: 1,
|
|
35
|
-
first_page_url: "first_page_url",
|
|
36
|
-
last_page_url: "last_page_url",
|
|
37
|
-
next_page_url: "next_page_url",
|
|
38
|
-
prev_page_url: "prev_page_url",
|
|
39
|
-
path: "path",
|
|
40
|
-
per_page: 1,
|
|
41
|
-
from: 0,
|
|
42
|
-
to: 1,
|
|
43
|
-
total: 1,
|
|
44
|
-
data: [
|
|
45
|
-
{
|
|
46
|
-
id: 1,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
});
|
|
50
|
-
const defaultHeaders = (): ITableHeader[] => [
|
|
51
|
-
{
|
|
52
|
-
title: "ID",
|
|
53
|
-
isSortable: false,
|
|
54
|
-
},
|
|
55
|
-
];
|
|
56
|
-
const defaultItemRenderer = (item: any) => (
|
|
57
|
-
<tr key={item.id}>
|
|
58
|
-
<td>{item.id}</td>
|
|
59
|
-
</tr>
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
it("should be rendered without issues", () => {
|
|
63
|
-
const component = shallow(
|
|
64
|
-
<TableHelperComponent
|
|
65
|
-
headers={defaultHeaders()}
|
|
66
|
-
renderItemFn={defaultItemRenderer}
|
|
67
|
-
isLoading
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
expect(component.exists()).toBeTruthy();
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("should be mount without issues", () => {
|
|
75
|
-
const component = mount(
|
|
76
|
-
<TableHelperComponent
|
|
77
|
-
headers={defaultHeaders()}
|
|
78
|
-
renderItemFn={defaultItemRenderer}
|
|
79
|
-
paginator={getPaginator()}
|
|
80
|
-
isLoading={false}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
expect(component.exists()).toBeTruthy();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("should act on refresh", () => {
|
|
88
|
-
const onRefreshFn = jest.fn();
|
|
89
|
-
|
|
90
|
-
mount(
|
|
91
|
-
<TableHelperComponent
|
|
92
|
-
headers={defaultHeaders()}
|
|
93
|
-
renderItemFn={defaultItemRenderer}
|
|
94
|
-
paginator={getPaginator()}
|
|
95
|
-
isLoading={false}
|
|
96
|
-
onRefreshFn={onRefreshFn}
|
|
97
|
-
/>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
expect(onRefreshFn).toHaveBeenCalledTimes(2);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
it("should act on manual refresh trigger", () => {
|
|
104
|
-
const onRefreshFn = jest.fn();
|
|
105
|
-
let refreshAt = 0;
|
|
106
|
-
|
|
107
|
-
const component = mount(
|
|
108
|
-
<TableHelperComponent
|
|
109
|
-
headers={defaultHeaders()}
|
|
110
|
-
renderItemFn={defaultItemRenderer}
|
|
111
|
-
paginator={getPaginator()}
|
|
112
|
-
isLoading={false}
|
|
113
|
-
onRefreshFn={onRefreshFn}
|
|
114
|
-
refreshAt={refreshAt}
|
|
115
|
-
/>
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
component.update();
|
|
119
|
-
|
|
120
|
-
act(() => {
|
|
121
|
-
refreshAt = 100;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
component.update();
|
|
125
|
-
|
|
126
|
-
expect(onRefreshFn).toHaveBeenCalledTimes(1);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it("should act on sort by header", () => {
|
|
130
|
-
const headers = defaultHeaders();
|
|
131
|
-
headers.push({
|
|
132
|
-
title: "Name",
|
|
133
|
-
key: "sortKey",
|
|
134
|
-
isSortable: true,
|
|
135
|
-
});
|
|
136
|
-
headers.push({
|
|
137
|
-
title: "E-mail",
|
|
138
|
-
isSortable: true,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
TableService.getHeaderClasses = jest.fn();
|
|
142
|
-
TableService.getSortDirection = jest.fn();
|
|
143
|
-
|
|
144
|
-
const component = mount(
|
|
145
|
-
<TableHelperComponent
|
|
146
|
-
headers={headers}
|
|
147
|
-
renderItemFn={defaultItemRenderer}
|
|
148
|
-
paginator={getPaginator()}
|
|
149
|
-
isLoading={false}
|
|
150
|
-
/>
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
act(() => {
|
|
154
|
-
component.find("th").at(1).prop("onClick")?.(
|
|
155
|
-
{} as React.MouseEvent<HTMLElement>
|
|
156
|
-
);
|
|
157
|
-
component.find("th").at(2).prop("onClick")?.(
|
|
158
|
-
{} as React.MouseEvent<HTMLElement>
|
|
159
|
-
);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
component.update();
|
|
163
|
-
|
|
164
|
-
expect(TableService.getHeaderClasses).toHaveBeenCalled();
|
|
165
|
-
expect(TableService.getSortDirection).toHaveBeenCalled();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("should act on per page change", () => {
|
|
169
|
-
const onRefreshFn = jest.fn();
|
|
170
|
-
const component = mount(
|
|
171
|
-
<TableHelperComponent
|
|
172
|
-
headers={defaultHeaders()}
|
|
173
|
-
renderItemFn={defaultItemRenderer}
|
|
174
|
-
paginator={getPaginator()}
|
|
175
|
-
isLoading={false}
|
|
176
|
-
onRefreshFn={onRefreshFn}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
component.update();
|
|
181
|
-
|
|
182
|
-
act(() => {
|
|
183
|
-
component.find(PerPageHelperComponent).at(0).prop("onChangeFn")?.(2);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
component.update();
|
|
187
|
-
|
|
188
|
-
expect(onRefreshFn).toHaveBeenCalled();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("should act on filter change", () => {
|
|
192
|
-
const onRefreshFn = jest.fn();
|
|
193
|
-
const component = mount(
|
|
194
|
-
<TableHelperComponent
|
|
195
|
-
headers={defaultHeaders()}
|
|
196
|
-
renderItemFn={defaultItemRenderer}
|
|
197
|
-
paginator={getPaginator()}
|
|
198
|
-
isLoading={false}
|
|
199
|
-
onRefreshFn={onRefreshFn}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
component.update();
|
|
204
|
-
|
|
205
|
-
act(() => {
|
|
206
|
-
component.find(FilterHelperComponent).at(0).prop("onClickFn")?.(
|
|
207
|
-
"next-filter"
|
|
208
|
-
);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
component.update();
|
|
212
|
-
|
|
213
|
-
expect(onRefreshFn).toHaveBeenCalled();
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it("should act on paginator's page change", () => {
|
|
217
|
-
const onRefreshFn = jest.fn();
|
|
218
|
-
const component = mount(
|
|
219
|
-
<TableHelperComponent
|
|
220
|
-
headers={defaultHeaders()}
|
|
221
|
-
renderItemFn={defaultItemRenderer}
|
|
222
|
-
paginator={getPaginator()}
|
|
223
|
-
isLoading={false}
|
|
224
|
-
onRefreshFn={onRefreshFn}
|
|
225
|
-
/>
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
component.update();
|
|
229
|
-
|
|
230
|
-
act(() => {
|
|
231
|
-
component.find(PaginationHelperComponent).at(0).prop("onPageChangeFn")?.(
|
|
232
|
-
2
|
|
233
|
-
);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
component.update();
|
|
237
|
-
|
|
238
|
-
expect(onRefreshFn).toHaveBeenCalled();
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("should redirect with external parameters", () => {
|
|
242
|
-
const onRefreshFn = jest.fn();
|
|
243
|
-
const component = mount(
|
|
244
|
-
<TableHelperComponent
|
|
245
|
-
headers={defaultHeaders()}
|
|
246
|
-
renderItemFn={defaultItemRenderer}
|
|
247
|
-
paginator={getPaginator()}
|
|
248
|
-
isLoading={false}
|
|
249
|
-
onRefreshFn={onRefreshFn}
|
|
250
|
-
/>
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
component.setProps({ externalFilters: { test: 1 } });
|
|
254
|
-
|
|
255
|
-
component.update();
|
|
256
|
-
|
|
257
|
-
expect(window.location.search.includes("&test=1")).toBeTruthy();
|
|
258
|
-
|
|
259
|
-
component.setProps({ externalFilters: { test: "test" } });
|
|
260
|
-
|
|
261
|
-
component.update();
|
|
262
|
-
|
|
263
|
-
expect(window.location.search.includes("&test=test")).toBeTruthy();
|
|
264
|
-
|
|
265
|
-
component.setProps({ externalFilters: {} });
|
|
266
|
-
|
|
267
|
-
component.update();
|
|
268
|
-
|
|
269
|
-
expect(window.location.search.includes("&test=test")).toBeFalsy();
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
describe("getFilterOptionsValue util", () => {
|
|
273
|
-
it("not change query value", () => {
|
|
274
|
-
const query = new URLSearchParams("&page=1");
|
|
275
|
-
|
|
276
|
-
expect(getFilterOptionsValue(query, { page: 2 }, "page")).toBe("1");
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it("not apply initial values", () => {
|
|
280
|
-
const query = new URLSearchParams("");
|
|
281
|
-
|
|
282
|
-
expect(getFilterOptionsValue(query, { page: 2 }, "page")).toBe(2);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("return default values for standard keys", () => {
|
|
286
|
-
const query = new URLSearchParams("");
|
|
287
|
-
|
|
288
|
-
expect(getFilterOptionsValue(query, {}, "page")).toBe(1);
|
|
289
|
-
expect(getFilterOptionsValue(query, {}, "perPage")).toBe(24);
|
|
290
|
-
expect(getFilterOptionsValue(query, {}, "filter")).toBe("");
|
|
291
|
-
expect(getFilterOptionsValue(query, {}, "sortKey")).toBe("id");
|
|
292
|
-
expect(getFilterOptionsValue(query, {}, "sortDirection")).toBe("asc");
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { shallow, mount } from "enzyme";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { TipTapEditor } from "../../src/tiptap-editor/TipTapEditor";
|
|
4
|
-
|
|
5
|
-
describe("TipTapEditorComponent", () => {
|
|
6
|
-
it("should be rendered without issues", () => {
|
|
7
|
-
const component = shallow(<TipTapEditor viewMode={false} />);
|
|
8
|
-
|
|
9
|
-
expect(component.exists()).toBeTruthy();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("should be mount without issues", () => {
|
|
13
|
-
const component = mount(
|
|
14
|
-
<TipTapEditor viewMode content="<p>Test Content</p>" />
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
expect(component.exists()).toBeTruthy();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should be disabled if it is disabled", () => {
|
|
21
|
-
const component = shallow(
|
|
22
|
-
<TipTapEditor disabled viewMode={false} content="<p>Test Content</p>" />
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
expect(component.exists()).toBeTruthy();
|
|
26
|
-
expect(component.children().at(1).hasClass("editor-disabled")).toBeTruthy();
|
|
27
|
-
});
|
|
28
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as useAuthApi from "@licklist/plugins/dist/hooks/Api/useAuthApi";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useAuthApiMock = (mockReturn: any = null) => {
|
|
8
|
-
const authApiMock = useAuthApi as jest.Mocked<typeof useAuthApi>;
|
|
9
|
-
|
|
10
|
-
return authApiMock.default.mockReturnValue(mockReturn);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default useAuthApiMock;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as useAuthHook from "@licklist/plugins/dist/context/user/hooks/useAuth";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useAuthMock = (mockReturn: any = null) => {
|
|
8
|
-
const useAuthHookMock = useAuthHook as jest.Mocked<typeof useAuthHook>;
|
|
9
|
-
|
|
10
|
-
return useAuthHookMock.default.mockReturnValue(mockReturn);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default useAuthMock;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import * as hook from "react-hook-form";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useFormMock = (mockReturn: any = {}) => {
|
|
8
|
-
const mock = hook as jest.Mocked<typeof hook>;
|
|
9
|
-
|
|
10
|
-
return mock.useForm.mockReturnValue({
|
|
11
|
-
register: jest.fn(),
|
|
12
|
-
handleSubmit: jest.fn(),
|
|
13
|
-
formState: {
|
|
14
|
-
dirtyFields: {
|
|
15
|
-
has: jest.fn(),
|
|
16
|
-
},
|
|
17
|
-
errors: jest.fn(),
|
|
18
|
-
},
|
|
19
|
-
setValue: jest.fn(),
|
|
20
|
-
getValues: jest.fn(),
|
|
21
|
-
control: jest.fn(),
|
|
22
|
-
watch: jest.fn(),
|
|
23
|
-
...mockReturn,
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default useFormMock;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as hook from "@licklist/plugins/dist/context/app/hooks/useNotification";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useNotificationMock = (mockReturn: any = null) => {
|
|
8
|
-
const mock = hook as jest.Mocked<typeof hook>;
|
|
9
|
-
|
|
10
|
-
return mock.default.mockImplementation(() => mockReturn);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default useNotificationMock;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as useUserHook from "@licklist/plugins/dist/hooks/Query/useQuery";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useQueryMock = (mockReturn: any = {}) => {
|
|
8
|
-
const useUserHookMock = useUserHook as jest.Mocked<typeof useUserHook>;
|
|
9
|
-
|
|
10
|
-
return useUserHookMock.default.mockReturnValue({
|
|
11
|
-
get: (key) => key,
|
|
12
|
-
...mockReturn,
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default useQueryMock;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as hook from "@licklist/plugins/dist/hooks/Api/useSocialApi";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useSocialApiMock = (mockReturn: any = {}) => {
|
|
8
|
-
const mock = hook as jest.Mocked<typeof hook>;
|
|
9
|
-
|
|
10
|
-
return mock.default.mockReturnValue({
|
|
11
|
-
getSocialProvider: jest.fn(),
|
|
12
|
-
redirectToProvider: jest.fn(),
|
|
13
|
-
registerFacebookCallback: jest.fn(),
|
|
14
|
-
registerTwitterCallback: jest.fn(),
|
|
15
|
-
registerCallback: jest.fn(),
|
|
16
|
-
...mockReturn,
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default useSocialApiMock;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as hook from "react-i18next";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useTranslationMock = (mockReturn: any = null) => {
|
|
8
|
-
const hookMock = hook as jest.Mocked<typeof hook>;
|
|
9
|
-
|
|
10
|
-
return hookMock.useTranslation.mockReturnValue(
|
|
11
|
-
mockReturn || {
|
|
12
|
-
t: jest.fn().mockReturnValue("test"),
|
|
13
|
-
}
|
|
14
|
-
);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default useTranslationMock;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as hook from "@licklist/plugins/dist/hooks/Api/useUserApi";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useUserApiMock = (mockReturn: any = {}) => {
|
|
8
|
-
const mock = hook as jest.Mocked<typeof hook>;
|
|
9
|
-
|
|
10
|
-
return mock.default.mockReturnValue({
|
|
11
|
-
profile: jest.fn(),
|
|
12
|
-
login: jest.fn(),
|
|
13
|
-
setAuthorizationToken: jest.fn(),
|
|
14
|
-
...mockReturn,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default useUserApiMock;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as useUserHook from "@licklist/plugins/dist/context/user/hooks/useUser";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Mocks custom hook
|
|
5
|
-
* @param mockReturn
|
|
6
|
-
*/
|
|
7
|
-
const useUserMock = (mockReturn: any = null) => {
|
|
8
|
-
const useUserHookMock = useUserHook as jest.Mocked<typeof useUserHook>;
|
|
9
|
-
|
|
10
|
-
return useUserHookMock.default.mockReturnValue(mockReturn);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default useUserMock;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { QueryClient, QueryClientProvider, setLogger } from "react-query";
|
|
4
|
-
|
|
5
|
-
const queryClient = new QueryClient({
|
|
6
|
-
defaultOptions: {
|
|
7
|
-
queries: {
|
|
8
|
-
// ✅ turns retries off
|
|
9
|
-
retry: false,
|
|
10
|
-
cacheTime: 0,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
setLogger({
|
|
16
|
-
// eslint-disable-next-line no-console
|
|
17
|
-
log: console.log,
|
|
18
|
-
// eslint-disable-next-line no-console
|
|
19
|
-
warn: console.warn,
|
|
20
|
-
// ✅ no more errors on the console
|
|
21
|
-
error: () => undefined,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const wrapper = ({ children }: PropsWithChildren<unknown>) => (
|
|
25
|
-
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
export { queryClient, wrapper };
|
package/tests/setupTests.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
|
2
|
-
// allows you to do things like:
|
|
3
|
-
// expect(element).toHaveTextContent(/react/i)
|
|
4
|
-
// learn more: https://github.com/testing-library/jest-dom
|
|
5
|
-
import "@testing-library/jest-dom";
|
|
6
|
-
import "@testing-library/jest-dom/extend-expect";
|
|
7
|
-
import { configure } from "enzyme";
|
|
8
|
-
import React16Adapter from "enzyme-adapter-react-16";
|
|
9
|
-
|
|
10
|
-
configure({ adapter: new React16Adapter() });
|