@licklist/design 0.63.2 → 0.63.3-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.
Files changed (143) hide show
  1. package/bitbucket-pipelines.yml +0 -8
  2. package/dist/date-time-button/DateTimeButton.js +1 -1
  3. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.d.ts.map +1 -1
  4. package/dist/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.js +1 -1
  5. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.d.ts.map +1 -1
  6. package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +1 -1
  7. package/dist/iframe/payment/order-items-table/utils/paymentSummary.d.ts.map +1 -1
  8. package/dist/product-set/control/DateAndRecurrenceInput.d.ts +1 -1
  9. package/dist/product-set/control/DateAndRecurrenceInput.d.ts.map +1 -1
  10. package/dist/product-set/control/DateAndRecurrenceInput.js +1 -1
  11. package/dist/product-set/control/DateInput.js +1 -1
  12. package/dist/product-set/control/ProductSetControl.d.ts +3 -2
  13. package/dist/product-set/control/ProductSetControl.d.ts.map +1 -1
  14. package/dist/product-set/control/ProductSetControl.js +1 -1
  15. package/dist/product-set/form/ProductCategoriesControl.d.ts +3 -1
  16. package/dist/product-set/form/ProductCategoriesControl.d.ts.map +1 -1
  17. package/dist/product-set/form/ProductCategoriesControl.js +1 -1
  18. package/dist/product-set/form/ProductSetForm.d.ts +6 -2
  19. package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
  20. package/dist/product-set/form/ProductSetForm.js +1 -1
  21. package/dist/product-set/form/ProductsControl.d.ts +3 -1
  22. package/dist/product-set/form/ProductsControl.d.ts.map +1 -1
  23. package/dist/product-set/form/ProductsControl.js +1 -1
  24. package/dist/product-set/form/StepsControl.d.ts +3 -1
  25. package/dist/product-set/form/StepsControl.d.ts.map +1 -1
  26. package/dist/product-set/form/StepsControl.js +1 -1
  27. package/dist/product-set/product/ProductControl.d.ts +1 -0
  28. package/dist/product-set/product/ProductControl.d.ts.map +1 -1
  29. package/dist/product-set/product/ProductControl.js +1 -1
  30. package/dist/product-set/step/StepControl.d.ts +2 -1
  31. package/dist/product-set/step/StepControl.d.ts.map +1 -1
  32. package/dist/product-set/step/StepControl.js +1 -1
  33. package/dist/provider/working-hours-input/WorkingHoursInputDescription.d.ts.map +1 -1
  34. package/dist/provider/working-hours-input/WorkingHoursInputDescription.js +1 -1
  35. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.d.ts.map +1 -1
  36. package/dist/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.js +1 -1
  37. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts +3 -1
  38. package/dist/recurring-date-picker-input/RecurringDatePickerInput.d.ts.map +1 -1
  39. package/dist/recurring-date-picker-input/RecurringDatePickerInput.js +1 -1
  40. package/dist/recurring-date-picker-input/utils.d.ts +5 -0
  41. package/dist/recurring-date-picker-input/utils.d.ts.map +1 -1
  42. package/dist/recurring-date-picker-input/utils.js +1 -1
  43. package/dist/sales/booking/results/components/ResultCard.d.ts.map +1 -1
  44. package/dist/sales/coupon/control/CouponFormControl.d.ts +2 -1
  45. package/dist/sales/coupon/control/CouponFormControl.d.ts.map +1 -1
  46. package/dist/sales/coupon/control/CouponFormControl.js +1 -1
  47. package/dist/sales/coupon/form/CouponFrom.d.ts +2 -2
  48. package/dist/sales/coupon/form/CouponFrom.d.ts.map +1 -1
  49. package/dist/sales/coupon/utils/index.d.ts +7 -0
  50. package/dist/sales/coupon/utils/index.d.ts.map +1 -0
  51. package/dist/sales/coupon/utils/index.js +1 -0
  52. package/dist/setting/admin/AdminSettingForm.d.ts +2 -2
  53. package/dist/setting/admin/AdminSettingForm.d.ts.map +1 -1
  54. package/dist/sortable-tree/SortableTreeItem.d.ts +1 -2
  55. package/dist/sortable-tree/SortableTreeItem.d.ts.map +1 -1
  56. package/dist/sortable-tree/SortableTreeItem.js +1 -1
  57. package/dist/styles/iframe-page/PageBody.scss +0 -1
  58. package/dist/styles/sales/BookingResults.scss +1 -1
  59. package/dist/styles/zones/ZoneForm.scss +2 -1
  60. package/dist/typeahead/Typeahead.d.ts +2 -1
  61. package/dist/typeahead/Typeahead.d.ts.map +1 -1
  62. package/dist/typeahead/Typeahead.js +1 -1
  63. package/dist/zone/form/ZoneForm.d.ts +2 -2
  64. package/dist/zone/form/ZoneForm.d.ts.map +1 -1
  65. package/dist/zone/form/ZoneForm.js +1 -1
  66. package/dist/zone/form/components/ZoneControl.d.ts +2 -2
  67. package/dist/zone/form/components/ZoneControl.d.ts.map +1 -1
  68. package/dist/zone/form/components/ZoneControl.js +1 -1
  69. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts +4 -4
  70. package/dist/zone/form/components/ZoneRecurrencesControl.d.ts.map +1 -1
  71. package/dist/zone/form/components/ZoneRecurrencesControl.js +1 -1
  72. package/dist/zone/form/utils/dates.d.ts.map +1 -1
  73. package/package.json +12 -37
  74. package/src/date-time-button/DateTimeButton.stories.tsx +2 -1
  75. package/src/date-time-button/DateTimeButton.tsx +7 -5
  76. package/src/events/edit-event-modal/component/SelectEventProductSet/SelectEventProductSet.tsx +14 -9
  77. package/src/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.tsx +2 -0
  78. package/src/iframe/payment/order-items-table/utils/paymentSummary.tsx +1 -0
  79. package/src/product-set/control/DateAndRecurrenceInput.tsx +3 -4
  80. package/src/product-set/control/DateInput.tsx +2 -2
  81. package/src/product-set/control/ProductSetControl.tsx +11 -4
  82. package/src/product-set/form/ProductCategoriesControl.tsx +15 -4
  83. package/src/product-set/form/ProductSetForm.tsx +13 -2
  84. package/src/product-set/form/ProductsControl.tsx +93 -77
  85. package/src/product-set/form/StepsControl.tsx +15 -7
  86. package/src/product-set/product/ProductControl.tsx +39 -39
  87. package/src/product-set/step/StepControl.tsx +4 -3
  88. package/src/provider/working-hours-input/WorkingHoursInputDescription.tsx +4 -18
  89. package/src/recurring-date-picker-input/RecurrenceIntervalAndFrequencyInput.tsx +40 -21
  90. package/src/recurring-date-picker-input/RecurringDatePickerInput.stories.tsx +13 -7
  91. package/src/recurring-date-picker-input/RecurringDatePickerInput.tsx +12 -1
  92. package/src/recurring-date-picker-input/utils.ts +90 -1
  93. package/src/sales/booking/results/components/ResultCard.tsx +0 -3
  94. package/src/sales/coupon/control/CouponFormControl.tsx +28 -51
  95. package/src/sales/coupon/form/CouponFrom.tsx +5 -15
  96. package/src/sales/coupon/utils/index.ts +13 -0
  97. package/src/setting/admin/AdminSettingForm.tsx +2 -2
  98. package/src/sortable-tree/SortableTreeItem.tsx +0 -3
  99. package/src/static/switch/BooleanSwitch.tsx +1 -1
  100. package/src/styles/iframe-page/PageBody.scss +0 -1
  101. package/src/styles/sales/BookingResults.scss +1 -1
  102. package/src/styles/zones/ZoneForm.scss +2 -1
  103. package/src/typeahead/Typeahead.tsx +16 -3
  104. package/src/zone/form/ZoneForm.tsx +3 -2
  105. package/src/zone/form/components/ZoneControl.tsx +3 -3
  106. package/src/zone/form/components/ZoneRecurrencesControl.tsx +7 -5
  107. package/src/zone/form/utils/dates.ts +9 -10
  108. package/jest.config.js +0 -29
  109. package/tests/Auth/Authorizer.test.tsx +0 -194
  110. package/tests/Auth/Layout/UserNavDropDown.test.tsx +0 -43
  111. package/tests/Auth/Layout/UserNavDropDownToggle.test.tsx +0 -33
  112. package/tests/Auth/Login/LoginComponent.test.tsx +0 -246
  113. package/tests/Auth/Login/LoginFormComponent.test.tsx +0 -182
  114. package/tests/Auth/Register/RegisterComponent.test.tsx +0 -285
  115. package/tests/Auth/Register/RegisterFormComponent.test.tsx +0 -170
  116. package/tests/Auth/Settings/Dashboard/IpInput.test.tsx +0 -130
  117. package/tests/Auth/Social/SocialCallbackComponent.test.tsx +0 -133
  118. package/tests/Auth/Social/SocialFormComponent.test.tsx +0 -118
  119. package/tests/FileUpload/FileUpload.test.tsx +0 -42
  120. package/tests/Notification/EmailTemplate.test.tsx +0 -82
  121. package/tests/ProductSet/ProductSetPopover.test.tsx +0 -40
  122. package/tests/Report/Report.test.tsx +0 -48
  123. package/tests/Sales/Coupon.test.tsx +0 -51
  124. package/tests/Sales/SalesAndVIews.test.tsx +0 -63
  125. package/tests/SnippetTemplates/SnippetTemplates.test.tsx +0 -56
  126. package/tests/Table/FilterHelperComponent.test.tsx +0 -88
  127. package/tests/Table/PaginationHelperComponent.test.tsx +0 -109
  128. package/tests/Table/PerPageHelperComponent.test.tsx +0 -34
  129. package/tests/Table/TableHelperComponent.test.tsx +0 -295
  130. package/tests/TipTapEditor/TipTapEditor.test.tsx +0 -28
  131. package/tests/__mock__/hooks/useAuthApi.ts +0 -13
  132. package/tests/__mock__/hooks/useAuthMock.ts +0 -13
  133. package/tests/__mock__/hooks/useFormMock.ts +0 -27
  134. package/tests/__mock__/hooks/useNotificationMock.ts +0 -13
  135. package/tests/__mock__/hooks/useQueryMock.ts +0 -16
  136. package/tests/__mock__/hooks/useSocialApiMock.ts +0 -20
  137. package/tests/__mock__/hooks/useTranslationMock.ts +0 -17
  138. package/tests/__mock__/hooks/useUserApiMock.ts +0 -18
  139. package/tests/__mock__/hooks/useUserMock.ts +0 -13
  140. package/tests/__mock__/styleMock.js +0 -1
  141. package/tests/__mock__/windowMock.ts +0 -5
  142. package/tests/packages/react-query.tsx +0 -28
  143. package/tests/setupTests.ts +0 -10
@@ -1,133 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { mount, shallow } from "enzyme";
3
- import * as React from "react";
4
- import { SocialCallbackComponent } from "../../../src/auth/Social/SocialCallbackComponent";
5
- import useAuthMock from "../../__mock__/hooks/useAuthMock";
6
- import useNotificationMock from "../../__mock__/hooks/useNotificationMock";
7
- import useQueryMock from "../../__mock__/hooks/useQueryMock";
8
- import useSocialApiMock from "../../__mock__/hooks/useSocialApiMock";
9
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
10
- import useUserApiMock from "../../__mock__/hooks/useUserApiMock";
11
- import useUserMock from "../../__mock__/hooks/useUserMock";
12
-
13
- jest.mock("react-i18next", () => ({
14
- Trans: jest.fn().mockReturnValue("test"),
15
- useTranslation: jest.fn(),
16
- }));
17
- jest.mock("react-router-dom", () => ({
18
- useParams: () => ({
19
- provider: "facebook",
20
- }),
21
- }));
22
- jest.mock("@licklist/plugins/dist/context/app/hooks/useNotification");
23
- jest.mock("@licklist/plugins/dist/context/user/hooks/useAuth");
24
- jest.mock("@licklist/plugins/dist/context/user/hooks/useUser");
25
- jest.mock("@licklist/plugins/dist/hooks/Api/useSocialApi");
26
- jest.mock("@licklist/plugins/dist/hooks/Api/useUserApi");
27
- jest.mock("@licklist/plugins/dist/hooks/Query/useQuery");
28
-
29
- beforeEach(() => {
30
- useQueryMock();
31
- useTranslationMock();
32
- useNotificationMock({
33
- danger: jest.fn(),
34
- success: jest.fn(),
35
- });
36
- useAuthMock({
37
- setSecrets: jest.fn(),
38
- });
39
- useUserMock({
40
- login: jest.fn(),
41
- });
42
- });
43
-
44
- afterAll(() => {
45
- jest.resetAllMocks();
46
- });
47
-
48
- describe("SocialCallbackComponent", () => {
49
- it("should be rendered without issues", () => {
50
- const component = shallow(<SocialCallbackComponent />);
51
-
52
- expect(component.exists()).toBeTruthy();
53
- });
54
-
55
- it("should fail on facebook callback", async () => {
56
- const getSocialProviderMock = jest.fn().mockReturnValue("facebook");
57
- const registerCallbackMock = jest
58
- .fn()
59
- .mockReturnValue(Promise.reject(new Error("test")));
60
- const notificationDangerMock = jest.fn();
61
- const notificationSuccessMock = jest.fn();
62
-
63
- useNotificationMock({
64
- danger: notificationDangerMock,
65
- success: notificationSuccessMock,
66
- });
67
-
68
- useSocialApiMock({
69
- getSocialProvider: getSocialProviderMock,
70
- registerCallback: registerCallbackMock,
71
- });
72
-
73
- mount(<SocialCallbackComponent />);
74
-
75
- expect(getSocialProviderMock).toHaveBeenCalledTimes(1);
76
- expect(registerCallbackMock).toHaveBeenCalledTimes(1);
77
- expect(notificationSuccessMock).toHaveBeenCalledTimes(0);
78
- });
79
-
80
- it("should succeed on facebook callback", async () => {
81
- const authResponse = {
82
- access_token: "access_token",
83
- refresh_token: "refresh_token",
84
- token_type: "token_type",
85
- expires_in: null,
86
- };
87
- const profileResponse = {
88
- id: 1,
89
- first_name: "first_name",
90
- last_name: "last_name",
91
- email: "email",
92
- role: null,
93
- };
94
-
95
- const getSocialProviderMock = jest.fn().mockReturnValue("facebook");
96
- const registerCallbackMock = jest
97
- .fn()
98
- .mockReturnValue(Promise.resolve(authResponse));
99
- const notificationDangerMock = jest.fn();
100
- const notificationSuccessMock = jest.fn();
101
- const profileMock = jest.fn(() =>
102
- Promise.resolve({
103
- error: false,
104
- message: profileResponse,
105
- })
106
- );
107
- const setAuthorizationTokenMock = jest.fn();
108
- const setSecretsMock = jest.fn();
109
-
110
- RouteService.redirectTo = jest.fn();
111
-
112
- useNotificationMock({
113
- danger: notificationDangerMock,
114
- success: notificationSuccessMock,
115
- });
116
- useSocialApiMock({
117
- getSocialProvider: getSocialProviderMock,
118
- registerCallback: registerCallbackMock,
119
- });
120
- useUserApiMock({
121
- profile: profileMock,
122
- setAuthorizationToken: setAuthorizationTokenMock,
123
- });
124
- useAuthMock({
125
- setSecrets: setSecretsMock,
126
- });
127
-
128
- mount(<SocialCallbackComponent />);
129
-
130
- expect(getSocialProviderMock).toHaveBeenCalledTimes(1);
131
- expect(registerCallbackMock).toHaveBeenCalledTimes(1);
132
- });
133
- });
@@ -1,118 +0,0 @@
1
- import RouteService from "@licklist/plugins/dist/services/Route/RouteService";
2
- import { mount, shallow } from "enzyme";
3
- import * as React from "react";
4
- import { act } from "react-dom/test-utils";
5
- import { SocialFormComponent } from "../../../src/auth/Social/SocialFormComponent";
6
- import useNotificationMock from "../../__mock__/hooks/useNotificationMock";
7
- import useSocialApiMock from "../../__mock__/hooks/useSocialApiMock";
8
- import useTranslationMock from "../../__mock__/hooks/useTranslationMock";
9
-
10
- jest.mock("react-i18next", () => ({
11
- Trans: jest.fn().mockReturnValue("test"),
12
- useTranslation: jest.fn(),
13
- }));
14
- jest.mock("@licklist/plugins/dist/context/app/hooks/useNotification");
15
- jest.mock("@licklist/plugins/dist/hooks/Api/useSocialApi");
16
-
17
- beforeEach(() => {
18
- useTranslationMock();
19
- useNotificationMock({
20
- danger: jest.fn(),
21
- success: jest.fn(),
22
- });
23
- });
24
-
25
- afterAll(() => {
26
- jest.resetAllMocks();
27
- });
28
-
29
- describe("SocialFormComponent", () => {
30
- it("should be rendered without issues", () => {
31
- const component = shallow(
32
- <SocialFormComponent isLoading={false} setIsLoading={() => false} />
33
- );
34
-
35
- expect(component.exists()).toBeTruthy();
36
- });
37
-
38
- it("should be disabled if it is loading", () => {
39
- const component = mount(
40
- <SocialFormComponent isLoading setIsLoading={() => false} />
41
- );
42
-
43
- expect(component.exists()).toBeTruthy();
44
- expect(component.find("SocialButton").at(0).prop("disabled")).toBeTruthy();
45
- expect(component.find("SocialButton").at(1).prop("disabled")).toBeTruthy();
46
- });
47
-
48
- it("should fail on facebook click action", async () => {
49
- const redirectToProviderMock = jest
50
- .fn()
51
- .mockReturnValue(Promise.reject(new Error("test")));
52
- const notificationDangerMock = jest.fn();
53
- const notificationSuccessMock = jest.fn();
54
-
55
- useNotificationMock({
56
- danger: notificationDangerMock,
57
- success: notificationSuccessMock,
58
- });
59
-
60
- useSocialApiMock({
61
- redirectToProvider: redirectToProviderMock,
62
- });
63
-
64
- const component = mount(
65
- <SocialFormComponent isLoading={false} setIsLoading={() => false} />
66
- );
67
-
68
- const facebook = component.find("SocialButton").at(0);
69
-
70
- await act(async () => {
71
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
72
- // @ts-ignore
73
- facebook.prop("onClick")!();
74
- });
75
-
76
- expect(redirectToProviderMock).toHaveBeenCalledTimes(1);
77
- expect(notificationDangerMock).toHaveBeenCalledTimes(2);
78
- expect(notificationSuccessMock).toHaveBeenCalledTimes(0);
79
- });
80
-
81
- it("should fail on twitter click action", async () => {
82
- const redirectTo = "/test";
83
- const redirectToProviderMock = jest.fn().mockReturnValue(
84
- Promise.resolve({
85
- redirect: redirectTo,
86
- })
87
- );
88
- const notificationDangerMock = jest.fn();
89
-
90
- RouteService.cleanRedirect = jest.fn();
91
-
92
- useNotificationMock({
93
- danger: notificationDangerMock,
94
- success: jest.fn(),
95
- });
96
-
97
- useSocialApiMock({
98
- redirectToProvider: redirectToProviderMock,
99
- });
100
-
101
- const component = mount(
102
- <SocialFormComponent isLoading={false} setIsLoading={() => false} />
103
- );
104
-
105
- const twitter = component.find("SocialButton").at(1);
106
-
107
- await act(async () => {
108
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
109
- // @ts-ignore
110
- twitter.prop("onClick")!();
111
- });
112
-
113
- expect(redirectToProviderMock).toHaveBeenCalledTimes(1);
114
- expect(notificationDangerMock).toHaveBeenCalledTimes(0);
115
- expect(RouteService.cleanRedirect).toHaveBeenCalledTimes(1);
116
- expect(RouteService.cleanRedirect).toHaveBeenCalledWith(redirectTo);
117
- });
118
- });
@@ -1,42 +0,0 @@
1
- import { render, screen } from "@testing-library/react";
2
- import userEvent from "@testing-library/user-event";
3
- import React from "react";
4
- import { FileUpload } from "../../src/file-upload/FileUpload";
5
-
6
- describe("FileUpload", () => {
7
- const file = new File(["(⌐□_□)"], "foo.png", { type: "image/png" });
8
-
9
- it("upload files", () => {
10
- render(<FileUpload allowedExtensions={["png"]} onFilesChange={() => {}} />);
11
- const uploader = screen.getByTitle("Upload Files") as HTMLInputElement;
12
- userEvent.upload(uploader, file);
13
-
14
- expect(uploader.files[0]).toStrictEqual(file);
15
- expect(uploader.files.item(0)).toStrictEqual(file);
16
- expect(uploader.files).toHaveLength(1);
17
- });
18
-
19
- it("should not upload file if its extension is not allowed", () => {
20
- render(<FileUpload allowedExtensions={["jpg"]} onFilesChange={() => {}} />);
21
- const uploader = screen.getByTitle("Upload Files") as HTMLInputElement;
22
- userEvent.upload(uploader, file, undefined, { applyAccept: true });
23
- expect(uploader.files[0]).not.toStrictEqual(file);
24
- expect(uploader.files).toHaveLength(0);
25
- });
26
-
27
- it("should display preview if it's enabled", () => {
28
- render(
29
- <FileUpload
30
- allowedExtensions={["png"]}
31
- onFilesChange={() => {}}
32
- enablePreview
33
- />
34
- );
35
- global.URL.createObjectURL = jest.fn();
36
- const uploader = screen.getByTitle("Upload Files") as HTMLInputElement;
37
- userEvent.upload(uploader, file);
38
- const imagePreview = screen.getByTestId("preview-image");
39
-
40
- expect(imagePreview).toBeInTheDocument();
41
- });
42
- });
@@ -1,82 +0,0 @@
1
- /* eslint-disable testing-library/render-result-naming-convention */
2
- import * as React from "react";
3
- import { render } from "@testing-library/react";
4
- import { createMemoryHistory } from "history";
5
- import { Router } from "react-router-dom";
6
- import { EmailTemplateCard } from "../../src/notification/email-template/card/EmailTemplateCard";
7
- import { EmailTemplateForm } from "../../src/notification/email-template/form/EmailTemplateForm";
8
- import useTranslationMock from "../__mock__/hooks/useTranslationMock";
9
-
10
- const history = createMemoryHistory();
11
-
12
- jest.mock("react-i18next", () => ({
13
- Trans: jest.fn().mockReturnValue("test"),
14
- useTranslation: jest.fn(),
15
- }));
16
-
17
- beforeEach(() => {
18
- useTranslationMock();
19
- });
20
-
21
- afterAll(() => {
22
- jest.resetAllMocks();
23
- });
24
-
25
- describe("EmailTemplate", () => {
26
- it("EmailTemplateCard should be rendered without issues", () => {
27
- const screen = render(
28
- <Router history={history as any}>
29
- <EmailTemplateCard
30
- hasPermission
31
- name="Email Template"
32
- subject="New Subject"
33
- href=""
34
- onRemove={() => {}}
35
- isDefault
36
- />
37
- </Router>
38
- );
39
- expect(screen.getByRole("button")).toBeInTheDocument();
40
- expect(screen.getByText("Email Template")).toBeInTheDocument();
41
- });
42
-
43
- it("EmailTemplateCard should not rendered button without valid permission", () => {
44
- const screen = render(
45
- <Router history={history as any}>
46
- <EmailTemplateCard
47
- hasPermission={false}
48
- name="Email Template"
49
- subject="New Subject"
50
- href=""
51
- onRemove={() => {}}
52
- isDefault
53
- />
54
- </Router>
55
- );
56
- expect(screen.queryByRole("button")).not.toBeInTheDocument();
57
- });
58
-
59
- it("EmailTemplateForm should be rendered without issues", () => {
60
- const screen = render(
61
- <EmailTemplateForm
62
- hasPermission
63
- isLoading={false}
64
- onSubmitSave={() => {}}
65
- placeholders={[]}
66
- />
67
- );
68
- expect(screen.getByRole("button")).toBeTruthy();
69
- });
70
-
71
- it("EmailTemplateForm should not rendered button without valid permission", () => {
72
- const screen = render(
73
- <EmailTemplateForm
74
- hasPermission={false}
75
- isLoading={false}
76
- onSubmitSave={() => {}}
77
- placeholders={[]}
78
- />
79
- );
80
- expect(screen.queryByRole("button")).not.toBeInTheDocument();
81
- });
82
- });
@@ -1,40 +0,0 @@
1
- import React from "react";
2
- import { mount } from "enzyme";
3
- import { Button } from "react-bootstrap";
4
- import { ProductSetPopover } from "../../src/product-set/popover/ProductSetPopover";
5
-
6
- describe("Product Set Popover", () => {
7
- it("should render without issues", () => {
8
- const component = mount(
9
- <ProductSetPopover>
10
- <>Lorem ipsum dolor sit</>
11
- </ProductSetPopover>
12
- );
13
- expect(component.exists()).toBeTruthy();
14
- });
15
-
16
- it("should be controlled if isVisible prop has been passed", () => {
17
- const component = mount(
18
- <ProductSetPopover isVisible={false}>
19
- <p id="popover-content">Some text here...</p>
20
- </ProductSetPopover>
21
- );
22
- const triggerButton = component.find(Button).first();
23
- triggerButton.simulate("click");
24
- const content = component.find("#popover-content");
25
-
26
- expect(content).toHaveLength(0);
27
- });
28
- it("should be uncontrolled if isVisible has not been passed", () => {
29
- const component = mount(
30
- <ProductSetPopover>
31
- <p id="popover-content">Some text here...</p>
32
- </ProductSetPopover>
33
- );
34
- const triggerButton = component.find(Button).first();
35
- triggerButton.simulate("click");
36
- const content = component.find("#popover-content");
37
-
38
- expect(content).toHaveLength(1);
39
- });
40
- });
@@ -1,48 +0,0 @@
1
- /* eslint-disable testing-library/render-result-naming-convention */
2
- import * as React from "react";
3
- import { render } from "@testing-library/react";
4
- import { createMemoryHistory } from "history";
5
- import { Router } from "react-router-dom";
6
- import { ReportCard } from "../../src/report/card/ReportCard";
7
- import { ReportForm } from "../../src/report/form/ReportForm";
8
- import useTranslationMock from "../__mock__/hooks/useTranslationMock";
9
-
10
- const history = createMemoryHistory();
11
-
12
- jest.mock("react-i18next", () => ({
13
- Trans: jest.fn().mockReturnValue("test"),
14
- useTranslation: jest.fn(),
15
- }));
16
-
17
- beforeEach(() => {
18
- useTranslationMock();
19
- });
20
-
21
- afterAll(() => {
22
- jest.resetAllMocks();
23
- });
24
-
25
- describe("Report", () => {
26
- it("ReportCard should be rendered without issues", () => {
27
- const screen = render(
28
- <Router history={history as any}>
29
- <ReportCard hasPermission name="Sales" onPress={() => {}} iconType="" />
30
- </Router>
31
- );
32
- expect(screen.getByText("Sales")).toBeInTheDocument();
33
- });
34
-
35
- it("ReportForm should be rendered without issues", () => {
36
- const screen = render(
37
- <ReportForm hasPermission onSubmit={() => {}} onHide={() => {}} />
38
- );
39
- expect(screen.getAllByRole("button")).toBeTruthy();
40
- });
41
-
42
- it("ReportForm should not rendered button without valid permission", () => {
43
- const screen = render(
44
- <ReportForm hasPermission={false} onSubmit={() => {}} onHide={() => {}} />
45
- );
46
- expect(screen.queryByRole("button")).not.toBeInTheDocument();
47
- });
48
- });
@@ -1,51 +0,0 @@
1
- /* eslint-disable testing-library/render-result-naming-convention */
2
- import * as React from "react";
3
- import { render } from "@testing-library/react";
4
- import { Router } from "react-router-dom";
5
- import { createMemoryHistory } from "history";
6
-
7
- import useTranslationMock from "../__mock__/hooks/useTranslationMock";
8
- import { CouponForm } from "../../src/sales/coupon/form";
9
-
10
- const history = createMemoryHistory();
11
-
12
- jest.mock("react-i18next", () => ({
13
- Trans: jest.fn().mockReturnValue("test"),
14
- useTranslation: jest.fn(),
15
- }));
16
-
17
- beforeEach(() => {
18
- useTranslationMock();
19
- });
20
-
21
- afterAll(() => {
22
- jest.resetAllMocks();
23
- });
24
-
25
- describe("CouponFrom", () => {
26
- it("CouponFrom should be rendered without issues with permission", () => {
27
- const screen = render(
28
- <Router history={history as any}>
29
- <CouponForm
30
- hasPermission
31
- onSubmit={() => {}}
32
- serverErrors={{ name: [""] }}
33
- />
34
- </Router>
35
- );
36
- expect(screen.getByRole("button")).toBeTruthy();
37
- });
38
-
39
- it("CouponFrom should be rendered without issues without permission", () => {
40
- const screen = render(
41
- <Router history={history as any}>
42
- <CouponForm
43
- hasPermission={false}
44
- onSubmit={() => {}}
45
- serverErrors={{ name: [""] }}
46
- />
47
- </Router>
48
- );
49
- expect(screen.queryByRole("button")).toBeFalsy();
50
- });
51
- });
@@ -1,63 +0,0 @@
1
- /* eslint-disable testing-library/render-result-naming-convention */
2
- import * as React from "react";
3
- import { render } from "@testing-library/react";
4
- import moment from "moment";
5
- import { IntlProvider } from "react-intl";
6
- import useTranslationMock from "../__mock__/hooks/useTranslationMock";
7
-
8
- import {
9
- ChartData,
10
- SalesAndViewsChart,
11
- } from "../../src/sales/sales-and-views/SalesAndViewsChart";
12
-
13
- jest.mock("react-i18next", () => ({
14
- Trans: jest.fn().mockReturnValue("test"),
15
- useTranslation: jest.fn(),
16
- }));
17
-
18
- beforeEach(() => {
19
- useTranslationMock();
20
- });
21
-
22
- afterAll(() => {
23
- jest.resetAllMocks();
24
- });
25
-
26
- function generateRandom() {
27
- return Math.floor(Math.random() * 100);
28
- }
29
-
30
- const genarateChartData = (): ChartData[] => {
31
- const chartData = [];
32
- const date = moment().subtract(90, "d");
33
-
34
- for (let i = 0; i < 90; i += 1) {
35
- chartData.push({
36
- id: i,
37
- sales: generateRandom(),
38
- views: generateRandom(),
39
- date: date.add(i, "d").format("YYYY-MM-DD"),
40
- });
41
- }
42
- return chartData;
43
- };
44
-
45
- describe("SalesAndViewsChart", () => {
46
- it("SalesAndViewsChart should be rendered without issues", () => {
47
- const data = genarateChartData();
48
-
49
- const screen = render(
50
- <IntlProvider locale="en" timeZone="Europe/London">
51
- <div style={{ height: "500px", width: "700px" }}>
52
- <SalesAndViewsChart
53
- data={data}
54
- handleFilter={() => {}}
55
- activePeriod="week"
56
- />
57
- </div>
58
- </IntlProvider>
59
- );
60
- const salesHeaderContainer = screen.getAllByText("test");
61
- expect(salesHeaderContainer[0]).toBeInTheDocument();
62
- });
63
- });
@@ -1,56 +0,0 @@
1
- /* eslint-disable testing-library/render-result-naming-convention */
2
- import * as React from "react";
3
- import { createMemoryHistory } from "history";
4
- import { Router } from "react-router-dom";
5
- import { render } from "@testing-library/react";
6
- import { SnippetTemplateCard } from "../../src/setting/dashboard/snippet-templates/card";
7
- import useTranslationMock from "../__mock__/hooks/useTranslationMock";
8
-
9
- const history = createMemoryHistory();
10
-
11
- jest.mock("react-i18next", () => ({
12
- Trans: jest.fn().mockReturnValue("test"),
13
- useTranslation: jest.fn(),
14
- }));
15
-
16
- beforeEach(() => {
17
- useTranslationMock();
18
- });
19
-
20
- afterAll(() => {
21
- jest.resetAllMocks();
22
- });
23
-
24
- describe("SnippetTemplates", () => {
25
- it("SnippetTemplate should be rendered without issues", () => {
26
- const screen = render(
27
- <Router history={history as any}>
28
- <SnippetTemplateCard
29
- hasPermission
30
- name="testSnippet"
31
- onRemove={() => {}}
32
- colors={["blue", "yellow"]}
33
- href="/"
34
- />
35
- </Router>
36
- );
37
-
38
- expect(screen.getByRole("button")).toBeTruthy();
39
- });
40
-
41
- it("SnippetTemplate without permission", async () => {
42
- const screen = render(
43
- <Router history={history as any}>
44
- <SnippetTemplateCard
45
- hasPermission={false}
46
- name="testSnippet"
47
- onRemove={() => {}}
48
- colors={["blue", "yellow"]}
49
- href="/"
50
- />
51
- </Router>
52
- );
53
-
54
- expect(screen.queryByRole("button")).toBeFalsy();
55
- });
56
- });