@wix/headless-bookings 0.0.97 → 0.0.98

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 (43) hide show
  1. package/cjs/dist/__mocks__/booking/booking-client-service.d.ts +9 -0
  2. package/cjs/dist/__mocks__/booking/booking-client-service.js +55 -0
  3. package/cjs/dist/__mocks__/booking/booking-mocks.d.ts +20 -0
  4. package/cjs/dist/__mocks__/booking/booking-mocks.js +76 -0
  5. package/{dist/__mocks__/services.d.ts → cjs/dist/__mocks__/services/services-mocks.d.ts} +5 -17
  6. package/cjs/dist/__mocks__/{services.js → services/services-mocks.js} +1 -27
  7. package/cjs/dist/__mocks__/time-slots/time-slots-client-service.d.ts +79 -0
  8. package/cjs/dist/__mocks__/time-slots/time-slots-client-service.js +120 -0
  9. package/{dist/__mocks__/time-slots.d.ts → cjs/dist/__mocks__/time-slots/time-slots-core.d.ts} +1 -28
  10. package/cjs/dist/__mocks__/{time-slots.js → time-slots/time-slots-core.js} +1 -115
  11. package/cjs/dist/__mocks__/time-slots/time-slots-mocks.d.ts +14 -0
  12. package/cjs/dist/__mocks__/time-slots/time-slots-mocks.js +50 -0
  13. package/cjs/dist/services/booking/booking.js +2 -1
  14. package/cjs/dist/services/constants.d.ts +12 -0
  15. package/cjs/dist/services/constants.js +11 -0
  16. package/cjs/dist/services/time-slot-list/time-slot-list.def.js +2 -1
  17. package/cjs/dist/services/time-slot-list/time-slot.js +2 -1
  18. package/dist/__mocks__/booking/booking-client-service.d.ts +9 -0
  19. package/dist/__mocks__/booking/booking-client-service.js +55 -0
  20. package/dist/__mocks__/booking/booking-mocks.d.ts +20 -0
  21. package/dist/__mocks__/booking/booking-mocks.js +76 -0
  22. package/{cjs/dist/__mocks__/services.d.ts → dist/__mocks__/services/services-mocks.d.ts} +5 -17
  23. package/dist/__mocks__/{services.js → services/services-mocks.js} +1 -27
  24. package/dist/__mocks__/time-slots/time-slots-client-service.d.ts +79 -0
  25. package/dist/__mocks__/time-slots/time-slots-client-service.js +120 -0
  26. package/{cjs/dist/__mocks__/time-slots.d.ts → dist/__mocks__/time-slots/time-slots-core.d.ts} +1 -28
  27. package/dist/__mocks__/{time-slots.js → time-slots/time-slots-core.js} +1 -115
  28. package/dist/__mocks__/time-slots/time-slots-mocks.d.ts +14 -0
  29. package/dist/__mocks__/time-slots/time-slots-mocks.js +50 -0
  30. package/dist/services/booking/booking.js +2 -1
  31. package/dist/services/constants.d.ts +12 -0
  32. package/dist/services/constants.js +11 -0
  33. package/dist/services/time-slot-list/time-slot-list.def.js +2 -1
  34. package/dist/services/time-slot-list/time-slot.js +2 -1
  35. package/package.json +2 -2
  36. package/cjs/dist/__mocks__/booking.d.ts +0 -87
  37. package/cjs/dist/__mocks__/booking.js +0 -229
  38. package/dist/__mocks__/booking.d.ts +0 -87
  39. package/dist/__mocks__/booking.js +0 -229
  40. /package/cjs/dist/__mocks__/{payment.d.ts → payment/payment-mocks.d.ts} +0 -0
  41. /package/cjs/dist/__mocks__/{payment.js → payment/payment-mocks.js} +0 -0
  42. /package/dist/__mocks__/{payment.d.ts → payment/payment-mocks.d.ts} +0 -0
  43. /package/dist/__mocks__/{payment.js → payment/payment-mocks.js} +0 -0
@@ -1,229 +0,0 @@
1
- import { mockService, mockServiceClass } from './services.js';
2
- import { vi } from 'vitest';
3
- export function mockSignal(initialValue) {
4
- let value = initialValue;
5
- return {
6
- get: () => value,
7
- peek: () => value,
8
- set: (newValue) => {
9
- value = newValue;
10
- },
11
- };
12
- }
13
- export function createMockSignalsService() {
14
- return {
15
- signal: mockSignal,
16
- // Re-evaluate the computed function on every get/peek (like real computed signals)
17
- computed: (fn) => ({
18
- get: () => fn(),
19
- peek: () => fn(),
20
- set: () => { }, // no-op for computed
21
- }),
22
- effect: vi.fn((fn) => {
23
- fn();
24
- }),
25
- };
26
- }
27
- export function createMockBookingService(initialSelections = []) {
28
- const serviceSelectionsSignal = mockSignal(initialSelections);
29
- const locationSignal = mockSignal(null);
30
- const timezoneSignal = mockSignal('UTC');
31
- const formSubmissionSignal = mockSignal(null);
32
- return {
33
- serviceSelections: serviceSelectionsSignal,
34
- location: locationSignal,
35
- timezone: timezoneSignal,
36
- formSubmission: formSubmissionSignal,
37
- actions: {
38
- updateItem: vi.fn(),
39
- setItem: vi.fn(),
40
- addItem: vi.fn(),
41
- removeItem: vi.fn(),
42
- clearItems: vi.fn(),
43
- setResource: vi.fn(),
44
- getResourceByType: vi.fn(),
45
- clearResourceByType: vi.fn(),
46
- setLocation: vi.fn(),
47
- clearLocation: vi.fn(),
48
- setTimezone: vi.fn(),
49
- setFormSubmission: vi.fn(),
50
- clearFormSubmission: vi.fn(),
51
- clearAll: vi.fn(),
52
- book: vi.fn(),
53
- },
54
- };
55
- }
56
- /**
57
- * Mock resource (staff member)
58
- */
59
- export const mockResource = {
60
- _id: 'resource-1',
61
- name: 'John Doe',
62
- email: 'john.doe@example.com',
63
- tag: 'STAFF',
64
- type: 'staff',
65
- };
66
- /**
67
- * Mock resource (another staff member)
68
- */
69
- export const mockResourceTwo = {
70
- _id: 'resource-2',
71
- name: 'Jane Smith',
72
- email: 'jane.smith@example.com',
73
- tag: 'STAFF',
74
- type: 'staff',
75
- };
76
- /**
77
- * Mock resource (room)
78
- */
79
- export const mockResourceRoom = {
80
- _id: 'resource-room-1',
81
- name: 'Conference Room A',
82
- tag: 'RESOURCE',
83
- type: 'room',
84
- };
85
- /**
86
- * Mock location (BUSINESS type with nested business object)
87
- */
88
- export const mockLocation = {
89
- _id: 'location-1',
90
- type: 'BUSINESS',
91
- business: {
92
- _id: 'location-1',
93
- name: 'Main Office',
94
- },
95
- };
96
- /**
97
- * Mock location (second)
98
- */
99
- export const mockLocationTwo = {
100
- _id: 'location-2',
101
- type: 'BUSINESS',
102
- business: {
103
- _id: 'location-2',
104
- name: 'Downtown Branch',
105
- },
106
- };
107
- /**
108
- * Mock time slot data
109
- */
110
- export const mockTimeSlot = {
111
- startDate: '2024-03-15T10:00:00Z',
112
- endDate: '2024-03-15T11:00:00Z',
113
- totalCapacity: 10,
114
- remainingCapacity: 5,
115
- scheduleId: 'schedule-123',
116
- resources: [mockResource],
117
- location: mockLocation,
118
- };
119
- /**
120
- * Mock time slot for afternoon
121
- */
122
- export const mockTimeSlotAfternoon = {
123
- startDate: '2024-03-15T14:00:00Z',
124
- endDate: '2024-03-15T15:00:00Z',
125
- totalCapacity: 10,
126
- remainingCapacity: 8,
127
- scheduleId: 'schedule-456',
128
- resources: [mockResourceTwo],
129
- location: mockLocationTwo,
130
- };
131
- /**
132
- * Mock service selection with all data
133
- */
134
- export const mockServiceSelection = {
135
- instanceId: 'instance-1',
136
- service: mockService,
137
- resources: [mockResource],
138
- timeSlot: mockTimeSlot,
139
- totalParticipants: 1,
140
- };
141
- /**
142
- * Mock service selection without time slot (incomplete)
143
- */
144
- export const mockServiceSelectionWithoutTimeSlot = {
145
- instanceId: 'instance-2',
146
- service: mockService,
147
- resources: [],
148
- totalParticipants: 1,
149
- };
150
- /**
151
- * Mock service selection for class
152
- */
153
- export const mockServiceSelectionClass = {
154
- instanceId: 'instance-3',
155
- service: mockServiceClass,
156
- resources: [mockResource],
157
- timeSlot: mockTimeSlotAfternoon,
158
- totalParticipants: 3,
159
- };
160
- /**
161
- * Mock form submission (contact info)
162
- */
163
- export const mockFormSubmission = {
164
- firstName: 'John',
165
- lastName: 'Doe',
166
- email: 'john.doe@example.com',
167
- phone: '+1234567890',
168
- };
169
- /**
170
- * Mock form submission (minimal)
171
- */
172
- export const mockFormSubmissionMinimal = {
173
- email: 'test@example.com',
174
- };
175
- /**
176
- * Mock form submission with custom fields
177
- */
178
- export const mockFormSubmissionWithCustomFields = {
179
- firstName: 'Jane',
180
- lastName: 'Smith',
181
- email: 'jane.smith@example.com',
182
- notes: 'Please call before the appointment',
183
- customField1: 'Custom value 1',
184
- };
185
- /**
186
- * Default timezone for tests
187
- */
188
- export const mockTimezone = 'America/New_York';
189
- /**
190
- * Mock booking service config (empty)
191
- */
192
- export const mockEmptyBookingConfig = {};
193
- /**
194
- * Mock booking service config with initial data
195
- */
196
- export const mockBookingConfigWithData = {
197
- serviceSelections: [mockServiceSelection],
198
- location: mockLocation,
199
- timezone: mockTimezone,
200
- formSubmission: mockFormSubmission,
201
- };
202
- /**
203
- * Mock booking service config with multiple selections
204
- */
205
- export const mockBookingConfigMultipleSelections = {
206
- serviceSelections: [mockServiceSelection, mockServiceSelectionClass],
207
- location: mockLocation,
208
- timezone: mockTimezone,
209
- formSubmission: mockFormSubmission,
210
- };
211
- /**
212
- * Helper to create a service selection with custom instanceId
213
- */
214
- export function createMockServiceSelection(overrides = {}) {
215
- const { instanceId: _, ...base } = mockServiceSelection;
216
- return {
217
- ...base,
218
- ...overrides,
219
- };
220
- }
221
- /**
222
- * Helper to create multiple service selections
223
- */
224
- export function createMockServiceSelections(count) {
225
- return Array.from({ length: count }, (_, i) => ({
226
- ...mockServiceSelection,
227
- instanceId: `instance-${i + 1}`,
228
- }));
229
- }