@licklist/design 0.62.2 → 0.62.3-dev.1
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/EditEventForm/EditEventForm.d.ts +3 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/EditEventForm/EditEventForm.js +1 -1
- package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts +3 -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 +3 -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.js +1 -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.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.d.ts.map +1 -1
- package/dist/product-set/control/DateInput.js +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts +1 -1
- package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.d.ts +4 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/hooks/useSortableTreeFunctions.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.d.ts.map +1 -1
- package/dist/product-set/product/ProductControl.js +1 -1
- package/dist/product-set/product/fixed-duration-fields/FixedDurationOptions.d.ts.map +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/RecurrenceAndFrequencyInput.d.ts.map +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 +12 -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/sales/booking/results/components/ResultCard.js +1 -1
- package/dist/sales/coupon/control/CouponFormControl.d.ts +2 -1
- package/dist/sales/coupon/control/CouponFormControl.d.ts.map +1 -1
- package/dist/sales/coupon/control/CouponFormControl.js +1 -1
- package/dist/sales/coupon/form/CouponFrom.d.ts +2 -2
- package/dist/sales/coupon/form/CouponFrom.d.ts.map +1 -1
- package/dist/sales/coupon/utils/index.d.ts +7 -0
- package/dist/sales/coupon/utils/index.d.ts.map +1 -0
- package/dist/sales/coupon/utils/index.js +1 -0
- package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
- package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
- package/dist/setting/dashboard/DashboardSettingForm.d.ts +1 -0
- package/dist/setting/dashboard/DashboardSettingForm.d.ts.map +1 -1
- package/dist/setting/dashboard/DashboardSettingForm.js +1 -1
- package/dist/styles/iframe-external-modal/IframeExternalModal.scss +1 -0
- package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +99 -113
- package/dist/styles/sales/BookingResults.scss +1 -1
- package/dist/typeahead/Typeahead.d.ts +2 -1
- package/dist/typeahead/Typeahead.d.ts.map +1 -1
- package/dist/typeahead/Typeahead.js +1 -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 +10 -35
- 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/EditEventForm/EditEventForm.tsx +4 -0
- package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +10 -8
- package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +4 -0
- package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +6 -6
- package/src/iframe/ryft/RyftPaymentForm.tsx +12 -4
- package/src/iframe/ryft/utils/ryft-form.ts +8 -4
- package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -2
- package/src/product-set/control/DateInput.tsx +2 -4
- package/src/product-set/control/ProductSetControl.tsx +1 -1
- package/src/product-set/form/ProductCategoriesControl.tsx +1 -1
- package/src/product-set/form/ProductSetForm.tsx +5 -1
- package/src/product-set/hooks/useSortableTreeFunctions.ts +2 -0
- package/src/product-set/product/ProductControl.tsx +38 -38
- package/src/product-set/product/fixed-duration-fields/FixedDurationOptions.tsx +0 -2
- package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
- package/src/recurring-date-picker-input/RecurrenceAndFrequencyInput.tsx +0 -1
- package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +11 -1
- package/src/recurring-date-picker-input/utils.ts +77 -0
- package/src/sales/booking/results/BookingResults.stories.tsx +3 -2
- package/src/sales/booking/results/components/ResultCard.tsx +2 -5
- package/src/sales/coupon/control/CouponFormControl.tsx +29 -50
- package/src/sales/coupon/form/CouponFrom.tsx +5 -15
- package/src/sales/coupon/utils/index.ts +13 -0
- package/src/setting/admin/AdminSettingForm.tsx +2 -2
- package/src/setting/dashboard/DashboardSettingForm.tsx +13 -0
- package/src/sortable-tree/SortableTreeItem.tsx +1 -1
- package/src/static/switch/BooleanSwitch.tsx +1 -1
- package/src/styles/iframe-external-modal/IframeExternalModal.scss +1 -0
- package/src/styles/ryft-payment-form/RyftPaymentForm.scss +99 -113
- package/src/styles/sales/BookingResults.scss +1 -1
- package/src/typeahead/Typeahead.tsx +16 -3
- 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,33 +0,0 @@
|
|
|
1
|
-
import { IUser } from "@licklist/plugins/dist/types/context/user/IUser";
|
|
2
|
-
import { shallow } from "enzyme";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { UserNavDropDownToggle } from "../../../src/auth/Layout/UserNavDropDownToggle";
|
|
5
|
-
import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
|
|
6
|
-
|
|
7
|
-
jest.mock("react-i18next");
|
|
8
|
-
jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
|
|
9
|
-
|
|
10
|
-
const user: IUser = {
|
|
11
|
-
id: 1,
|
|
12
|
-
first_name: "first_name",
|
|
13
|
-
last_name: "last_name",
|
|
14
|
-
email: "email",
|
|
15
|
-
user_roles: [],
|
|
16
|
-
user_detail: {
|
|
17
|
-
postcode: "",
|
|
18
|
-
birthday: "",
|
|
19
|
-
phone: "",
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
describe("UserNavDropDownToggle", () => {
|
|
24
|
-
it("should be rendered without issues", () => {
|
|
25
|
-
useTranslationMock({
|
|
26
|
-
t: jest.fn(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const component = shallow(<UserNavDropDownToggle user={user} />);
|
|
30
|
-
|
|
31
|
-
expect(component.exists()).toBeTruthy();
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
|
|
2
|
-
import { UserLoginRequest } from "@licklist/plugins/dist/types/Request/UserLoginRequest";
|
|
3
|
-
import { mount, shallow } from "enzyme";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import { act } from "react-dom/test-utils";
|
|
6
|
-
import { MemoryRouter } from "react-router-dom";
|
|
7
|
-
import { LoginComponent, LoginFormComponent } from "../../../src/auth/Login";
|
|
8
|
-
import useAuthMock from "../../__mock__/hooks/useAuthMock";
|
|
9
|
-
import useFormMock from "../../__mock__/hooks/useFormMock";
|
|
10
|
-
import useNotificationMock from "../../__mock__/hooks/useNotificationMock";
|
|
11
|
-
import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
|
|
12
|
-
import useUserApiMock from "../../__mock__/hooks/useUserApiMock";
|
|
13
|
-
import useUserMock from "../../__mock__/hooks/useUserMock";
|
|
14
|
-
|
|
15
|
-
jest.mock("react-i18next", () => ({
|
|
16
|
-
Trans: jest.fn().mockReturnValue("test"),
|
|
17
|
-
useTranslation: jest.fn(),
|
|
18
|
-
}));
|
|
19
|
-
jest.mock("react-hook-form");
|
|
20
|
-
jest.mock("@licklist/plugins/dist/context/app/hooks/useNotification");
|
|
21
|
-
jest.mock("@licklist/plugins/dist/context/user/hooks/useAuth");
|
|
22
|
-
jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
|
|
23
|
-
jest.mock("@licklist/plugins/dist/hooks/Api/useUserApi");
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
useTranslationMock();
|
|
27
|
-
useNotificationMock({
|
|
28
|
-
danger: jest.fn(),
|
|
29
|
-
success: jest.fn(),
|
|
30
|
-
});
|
|
31
|
-
useAuthMock({
|
|
32
|
-
setSecrets: jest.fn(),
|
|
33
|
-
});
|
|
34
|
-
useUserMock({
|
|
35
|
-
login: jest.fn(),
|
|
36
|
-
clearInvitation: jest.fn(),
|
|
37
|
-
});
|
|
38
|
-
useFormMock();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterAll(() => {
|
|
42
|
-
jest.resetAllMocks();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe("LoginComponent", () => {
|
|
46
|
-
it("should be rendered without issues", () => {
|
|
47
|
-
const component = shallow(
|
|
48
|
-
<MemoryRouter initialEntries={["/"]}>
|
|
49
|
-
<LoginComponent />
|
|
50
|
-
</MemoryRouter>
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
expect(component.exists()).toBeTruthy();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("should show danger notification if login did not succeed", async () => {
|
|
57
|
-
let component: any;
|
|
58
|
-
|
|
59
|
-
const notificationDangerMock = jest.fn();
|
|
60
|
-
const notificationSuccessMock = jest.fn();
|
|
61
|
-
const loginMock = jest.fn(() => Promise.reject(new Error("danger")));
|
|
62
|
-
const profileMock = jest.fn();
|
|
63
|
-
|
|
64
|
-
useNotificationMock({
|
|
65
|
-
danger: notificationDangerMock,
|
|
66
|
-
success: notificationSuccessMock,
|
|
67
|
-
});
|
|
68
|
-
useUserApiMock({
|
|
69
|
-
login: loginMock,
|
|
70
|
-
profile: profileMock,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
RouteService.redirectTo = jest.fn();
|
|
74
|
-
|
|
75
|
-
act(() => {
|
|
76
|
-
component = mount(
|
|
77
|
-
<MemoryRouter>
|
|
78
|
-
<LoginComponent />
|
|
79
|
-
</MemoryRouter>
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
await act(async () => {
|
|
84
|
-
const credentials: UserLoginRequest = {
|
|
85
|
-
email: "email",
|
|
86
|
-
password: "password",
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
await component.find(LoginFormComponent).prop("onSubmit")(credentials);
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
component.update();
|
|
93
|
-
|
|
94
|
-
expect(component.exists()).toBeTruthy();
|
|
95
|
-
expect(loginMock).toHaveBeenCalledTimes(1);
|
|
96
|
-
expect(notificationDangerMock).toHaveBeenCalledTimes(1);
|
|
97
|
-
expect(profileMock).toHaveBeenCalledTimes(0);
|
|
98
|
-
expect(notificationSuccessMock).toHaveBeenCalledTimes(0);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should show danger notification if profile did not succeed", async () => {
|
|
102
|
-
let component: any;
|
|
103
|
-
|
|
104
|
-
const loginResponse = {
|
|
105
|
-
access_token: "access_token",
|
|
106
|
-
refresh_token: "refresh_token",
|
|
107
|
-
token_type: "token_type",
|
|
108
|
-
expires_in: null,
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
const notificationDangerMock = jest.fn();
|
|
112
|
-
const notificationSuccessMock = jest.fn();
|
|
113
|
-
const loginMock = jest.fn(() => Promise.resolve(loginResponse));
|
|
114
|
-
const profileMock = jest.fn(() => Promise.reject(new Error("danger")));
|
|
115
|
-
const setAuthorizationTokenMock = jest.fn();
|
|
116
|
-
const setSecretsMock = jest.fn();
|
|
117
|
-
|
|
118
|
-
useNotificationMock({
|
|
119
|
-
danger: notificationDangerMock,
|
|
120
|
-
success: notificationSuccessMock,
|
|
121
|
-
});
|
|
122
|
-
useUserApiMock({
|
|
123
|
-
login: loginMock,
|
|
124
|
-
profile: profileMock,
|
|
125
|
-
setAuthorizationToken: setAuthorizationTokenMock,
|
|
126
|
-
});
|
|
127
|
-
useAuthMock({
|
|
128
|
-
setSecrets: setSecretsMock,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
RouteService.redirectTo = jest.fn();
|
|
132
|
-
|
|
133
|
-
act(() => {
|
|
134
|
-
component = mount(
|
|
135
|
-
<MemoryRouter>
|
|
136
|
-
<LoginComponent />
|
|
137
|
-
</MemoryRouter>
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
await act(async () => {
|
|
142
|
-
const credentials: UserLoginRequest = {
|
|
143
|
-
email: "email",
|
|
144
|
-
password: "password",
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
await component.find(LoginFormComponent).prop("onSubmit")(credentials);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
component.update();
|
|
151
|
-
|
|
152
|
-
expect(component.exists()).toBeTruthy();
|
|
153
|
-
expect(loginMock).toHaveBeenCalledTimes(1);
|
|
154
|
-
expect(setSecretsMock).toHaveBeenCalledTimes(1);
|
|
155
|
-
expect(setSecretsMock).toHaveBeenCalledWith(loginResponse);
|
|
156
|
-
expect(setAuthorizationTokenMock).toHaveBeenCalledTimes(1);
|
|
157
|
-
expect(setAuthorizationTokenMock).toHaveBeenCalledWith(
|
|
158
|
-
loginResponse.access_token
|
|
159
|
-
);
|
|
160
|
-
expect(profileMock).toHaveBeenCalledTimes(1);
|
|
161
|
-
expect(notificationDangerMock).toHaveBeenCalledTimes(1);
|
|
162
|
-
expect(notificationSuccessMock).toHaveBeenCalledTimes(0);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it("should show success notification if login and profile did succeed", async () => {
|
|
166
|
-
let component: any;
|
|
167
|
-
|
|
168
|
-
const loginResponse = {
|
|
169
|
-
access_token: "access_token",
|
|
170
|
-
refresh_token: "refresh_token",
|
|
171
|
-
token_type: "token_type",
|
|
172
|
-
expires_in: null,
|
|
173
|
-
};
|
|
174
|
-
const profileResponse = {
|
|
175
|
-
id: 1,
|
|
176
|
-
first_name: "first_name",
|
|
177
|
-
last_name: "last_name",
|
|
178
|
-
email: "email",
|
|
179
|
-
role: null,
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const notificationDangerMock = jest.fn();
|
|
183
|
-
const notificationSuccessMock = jest.fn();
|
|
184
|
-
const loginMock = jest.fn(() => Promise.resolve(loginResponse));
|
|
185
|
-
const profileMock = jest.fn(() =>
|
|
186
|
-
Promise.resolve({
|
|
187
|
-
data: profileResponse,
|
|
188
|
-
})
|
|
189
|
-
);
|
|
190
|
-
const setAuthorizationTokenMock = jest.fn();
|
|
191
|
-
const setSecretsMock = jest.fn();
|
|
192
|
-
const userLoginMock = jest.fn();
|
|
193
|
-
|
|
194
|
-
useNotificationMock({
|
|
195
|
-
danger: notificationDangerMock,
|
|
196
|
-
success: notificationSuccessMock,
|
|
197
|
-
});
|
|
198
|
-
useUserApiMock({
|
|
199
|
-
login: loginMock,
|
|
200
|
-
profile: profileMock,
|
|
201
|
-
setAuthorizationToken: setAuthorizationTokenMock,
|
|
202
|
-
});
|
|
203
|
-
useAuthMock({
|
|
204
|
-
setSecrets: setSecretsMock,
|
|
205
|
-
});
|
|
206
|
-
useUserMock({
|
|
207
|
-
login: userLoginMock,
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
RouteService.redirectTo = jest.fn();
|
|
211
|
-
|
|
212
|
-
act(() => {
|
|
213
|
-
component = mount(
|
|
214
|
-
<MemoryRouter>
|
|
215
|
-
<LoginComponent />
|
|
216
|
-
</MemoryRouter>
|
|
217
|
-
);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
await act(async () => {
|
|
221
|
-
const credentials: UserLoginRequest = {
|
|
222
|
-
email: "email",
|
|
223
|
-
password: "password",
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
await component.find(LoginFormComponent).prop("onSubmit")(credentials);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
component.update();
|
|
230
|
-
|
|
231
|
-
expect(component.exists()).toBeTruthy();
|
|
232
|
-
expect(loginMock).toHaveBeenCalledTimes(1);
|
|
233
|
-
expect(setSecretsMock).toHaveBeenCalledTimes(1);
|
|
234
|
-
expect(setSecretsMock).toHaveBeenCalledWith(loginResponse);
|
|
235
|
-
expect(setAuthorizationTokenMock).toHaveBeenCalledTimes(1);
|
|
236
|
-
expect(setAuthorizationTokenMock).toHaveBeenCalledWith(
|
|
237
|
-
loginResponse.access_token
|
|
238
|
-
);
|
|
239
|
-
expect(profileMock).toHaveBeenCalledTimes(1);
|
|
240
|
-
expect(userLoginMock).toHaveBeenCalledTimes(1);
|
|
241
|
-
expect(userLoginMock).toHaveBeenCalledWith(profileResponse);
|
|
242
|
-
expect(notificationDangerMock).toHaveBeenCalledTimes(0);
|
|
243
|
-
expect(notificationSuccessMock).toHaveBeenCalledTimes(1);
|
|
244
|
-
expect(RouteService.redirectTo).toHaveBeenCalledTimes(1);
|
|
245
|
-
});
|
|
246
|
-
});
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/* eslint-disable testing-library/no-unnecessary-act */
|
|
2
|
-
/* eslint-disable testing-library/no-node-access */
|
|
3
|
-
/* eslint-disable testing-library/no-container */
|
|
4
|
-
import { mount, shallow } from "enzyme";
|
|
5
|
-
import * as React from "react";
|
|
6
|
-
import { act } from "react-dom/test-utils";
|
|
7
|
-
import { fireEvent, render } from "@testing-library/react";
|
|
8
|
-
import { LoginFormComponent } from "../../../src/auth/Login/LoginFormComponent";
|
|
9
|
-
import useFormMock from "../../__mock__/hooks/useFormMock";
|
|
10
|
-
import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
|
|
11
|
-
|
|
12
|
-
jest.mock("react-i18next", () => ({
|
|
13
|
-
Trans: jest.fn().mockReturnValue("test"),
|
|
14
|
-
useTranslation: jest.fn(),
|
|
15
|
-
}));
|
|
16
|
-
jest.mock("react-hook-form");
|
|
17
|
-
jest.mock("@licklist/plugins/dist/context/app/hooks/useNotification");
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
useTranslationMock();
|
|
21
|
-
useFormMock();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
afterAll(() => {
|
|
25
|
-
jest.resetAllMocks();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
describe("LoginFormComponent", () => {
|
|
29
|
-
it("should be rendered without issues", () => {
|
|
30
|
-
const component = shallow(
|
|
31
|
-
<LoginFormComponent
|
|
32
|
-
isLoading={false}
|
|
33
|
-
setIsLoading={() => false}
|
|
34
|
-
invitation={null}
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
expect(component.exists()).toBeTruthy();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("should be disabled if it is loading", () => {
|
|
42
|
-
const component = mount(
|
|
43
|
-
<LoginFormComponent
|
|
44
|
-
isLoading
|
|
45
|
-
setIsLoading={() => false}
|
|
46
|
-
invitation={null}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
expect(component.exists()).toBeTruthy();
|
|
51
|
-
expect(
|
|
52
|
-
component.find({ name: "email" }).at(0).prop("disabled")
|
|
53
|
-
).toBeTruthy();
|
|
54
|
-
expect(
|
|
55
|
-
component.find({ name: "password" }).at(0).prop("disabled")
|
|
56
|
-
).toBeTruthy();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should be disabled if invitation exist", () => {
|
|
60
|
-
const component = mount(
|
|
61
|
-
<LoginFormComponent
|
|
62
|
-
isLoading={false}
|
|
63
|
-
setIsLoading={() => false}
|
|
64
|
-
invitation={{
|
|
65
|
-
email: "test@test.test",
|
|
66
|
-
user_exists: false,
|
|
67
|
-
invitation_hash: "test",
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
expect(component.exists()).toBeTruthy();
|
|
73
|
-
expect(
|
|
74
|
-
component.find({ name: "email" }).at(0).prop("disabled")
|
|
75
|
-
).toBeTruthy();
|
|
76
|
-
expect(
|
|
77
|
-
component.find({ name: "password" }).at(0).prop("disabled")
|
|
78
|
-
).toBeFalsy();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should set value on input change", () => {
|
|
82
|
-
const setValueMock = jest.fn();
|
|
83
|
-
|
|
84
|
-
useFormMock({
|
|
85
|
-
setValue: setValueMock,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const component = mount(
|
|
89
|
-
<LoginFormComponent
|
|
90
|
-
isLoading={false}
|
|
91
|
-
setIsLoading={() => false}
|
|
92
|
-
invitation={null}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
95
|
-
|
|
96
|
-
const emailEvent = {
|
|
97
|
-
currentTarget: {
|
|
98
|
-
name: "email",
|
|
99
|
-
value: "test",
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const passwordEvent = {
|
|
104
|
-
currentTarget: {
|
|
105
|
-
name: "password",
|
|
106
|
-
value: "test",
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
act(() => {
|
|
111
|
-
component.find({ name: "email" }).at(1).prop("onChange")(emailEvent);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
expect(setValueMock).toHaveBeenCalledTimes(1);
|
|
115
|
-
expect(setValueMock).toHaveBeenCalledWith(
|
|
116
|
-
emailEvent.currentTarget.name,
|
|
117
|
-
emailEvent.currentTarget.value
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
act(() => {
|
|
121
|
-
component.find({ name: "password" }).at(1).prop("onChange")(
|
|
122
|
-
passwordEvent
|
|
123
|
-
);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
expect(setValueMock).toHaveBeenCalledTimes(2);
|
|
127
|
-
expect(setValueMock).toHaveBeenLastCalledWith(
|
|
128
|
-
passwordEvent.currentTarget.name,
|
|
129
|
-
passwordEvent.currentTarget.value
|
|
130
|
-
);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it("should handle submit action", async () => {
|
|
134
|
-
const onSubmitMock = jest.fn();
|
|
135
|
-
const handleSubmitMock = jest
|
|
136
|
-
.fn()
|
|
137
|
-
.mockImplementation(
|
|
138
|
-
(callback: (e: any) => void) => (e: any) => callback(e)
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
useFormMock({
|
|
142
|
-
handleSubmit: handleSubmitMock,
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const { container } = render(
|
|
146
|
-
<LoginFormComponent
|
|
147
|
-
isLoading={false}
|
|
148
|
-
setIsLoading={() => false}
|
|
149
|
-
onSubmit={onSubmitMock}
|
|
150
|
-
invitation={null}
|
|
151
|
-
/>
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
const emailEvent = {
|
|
155
|
-
currentTarget: {
|
|
156
|
-
name: "email",
|
|
157
|
-
value: "email",
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const passwordEvent = {
|
|
162
|
-
currentTarget: {
|
|
163
|
-
name: "password",
|
|
164
|
-
value: "password",
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const email = container.querySelector('input[name="email"]');
|
|
169
|
-
const password = container.querySelector('input[name="password"]');
|
|
170
|
-
const submit = container.querySelector('button[type="submit"]');
|
|
171
|
-
|
|
172
|
-
fireEvent.input(email!, emailEvent);
|
|
173
|
-
fireEvent.input(password!, passwordEvent);
|
|
174
|
-
|
|
175
|
-
await act(async () => {
|
|
176
|
-
fireEvent.submit(submit!);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
expect(handleSubmitMock).toHaveBeenCalledTimes(1);
|
|
180
|
-
expect(onSubmitMock).toHaveBeenCalledTimes(1);
|
|
181
|
-
});
|
|
182
|
-
});
|