@wix/headless-bookings 0.0.97 → 0.0.99

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 (45) 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/service-list/service-list.js +1 -0
  17. package/cjs/dist/services/time-slot-list/time-slot-list.def.js +2 -1
  18. package/cjs/dist/services/time-slot-list/time-slot.js +2 -1
  19. package/dist/__mocks__/booking/booking-client-service.d.ts +9 -0
  20. package/dist/__mocks__/booking/booking-client-service.js +55 -0
  21. package/dist/__mocks__/booking/booking-mocks.d.ts +20 -0
  22. package/dist/__mocks__/booking/booking-mocks.js +76 -0
  23. package/{cjs/dist/__mocks__/services.d.ts → dist/__mocks__/services/services-mocks.d.ts} +5 -17
  24. package/dist/__mocks__/{services.js → services/services-mocks.js} +1 -27
  25. package/dist/__mocks__/time-slots/time-slots-client-service.d.ts +79 -0
  26. package/dist/__mocks__/time-slots/time-slots-client-service.js +120 -0
  27. package/{cjs/dist/__mocks__/time-slots.d.ts → dist/__mocks__/time-slots/time-slots-core.d.ts} +1 -28
  28. package/dist/__mocks__/{time-slots.js → time-slots/time-slots-core.js} +1 -115
  29. package/dist/__mocks__/time-slots/time-slots-mocks.d.ts +14 -0
  30. package/dist/__mocks__/time-slots/time-slots-mocks.js +50 -0
  31. package/dist/services/booking/booking.js +2 -1
  32. package/dist/services/constants.d.ts +12 -0
  33. package/dist/services/constants.js +11 -0
  34. package/dist/services/service-list/service-list.js +1 -0
  35. package/dist/services/time-slot-list/time-slot-list.def.js +2 -1
  36. package/dist/services/time-slot-list/time-slot.js +2 -1
  37. package/package.json +2 -2
  38. package/cjs/dist/__mocks__/booking.d.ts +0 -87
  39. package/cjs/dist/__mocks__/booking.js +0 -229
  40. package/dist/__mocks__/booking.d.ts +0 -87
  41. package/dist/__mocks__/booking.js +0 -229
  42. /package/cjs/dist/__mocks__/{payment.d.ts → payment/payment-mocks.d.ts} +0 -0
  43. /package/cjs/dist/__mocks__/{payment.js → payment/payment-mocks.js} +0 -0
  44. /package/dist/__mocks__/{payment.d.ts → payment/payment-mocks.d.ts} +0 -0
  45. /package/dist/__mocks__/{payment.js → payment/payment-mocks.js} +0 -0
@@ -1,87 +0,0 @@
1
- import type { FormValues } from '@wix/form-public';
2
- import type { Location } from '@wix/auto_sdk_bookings_services';
3
- import type { ServiceSelection, ServiceSelectionTimeSlot, BookingServiceConfig, BookingService, ExtendedResource } from '../services/booking/booking.js';
4
- import type { Signal } from '@wix/services-definitions/core-services/signals';
5
- export declare function mockSignal<T>(initialValue: T): Signal<T>;
6
- export declare function createMockSignalsService(): {
7
- signal: typeof mockSignal;
8
- computed: <T>(fn: () => T) => Signal<T>;
9
- effect: (fn: () => void) => void;
10
- };
11
- export declare function createMockBookingService(initialSelections?: ServiceSelection[]): BookingService;
12
- /**
13
- * Mock resource (staff member)
14
- */
15
- export declare const mockResource: ExtendedResource;
16
- /**
17
- * Mock resource (another staff member)
18
- */
19
- export declare const mockResourceTwo: ExtendedResource;
20
- /**
21
- * Mock resource (room)
22
- */
23
- export declare const mockResourceRoom: ExtendedResource;
24
- /**
25
- * Mock location (BUSINESS type with nested business object)
26
- */
27
- export declare const mockLocation: Location;
28
- /**
29
- * Mock location (second)
30
- */
31
- export declare const mockLocationTwo: Location;
32
- /**
33
- * Mock time slot data
34
- */
35
- export declare const mockTimeSlot: ServiceSelectionTimeSlot;
36
- /**
37
- * Mock time slot for afternoon
38
- */
39
- export declare const mockTimeSlotAfternoon: ServiceSelectionTimeSlot;
40
- /**
41
- * Mock service selection with all data
42
- */
43
- export declare const mockServiceSelection: ServiceSelection;
44
- /**
45
- * Mock service selection without time slot (incomplete)
46
- */
47
- export declare const mockServiceSelectionWithoutTimeSlot: ServiceSelection;
48
- /**
49
- * Mock service selection for class
50
- */
51
- export declare const mockServiceSelectionClass: ServiceSelection;
52
- /**
53
- * Mock form submission (contact info)
54
- */
55
- export declare const mockFormSubmission: FormValues;
56
- /**
57
- * Mock form submission (minimal)
58
- */
59
- export declare const mockFormSubmissionMinimal: FormValues;
60
- /**
61
- * Mock form submission with custom fields
62
- */
63
- export declare const mockFormSubmissionWithCustomFields: FormValues;
64
- /**
65
- * Default timezone for tests
66
- */
67
- export declare const mockTimezone = "America/New_York";
68
- /**
69
- * Mock booking service config (empty)
70
- */
71
- export declare const mockEmptyBookingConfig: BookingServiceConfig;
72
- /**
73
- * Mock booking service config with initial data
74
- */
75
- export declare const mockBookingConfigWithData: BookingServiceConfig;
76
- /**
77
- * Mock booking service config with multiple selections
78
- */
79
- export declare const mockBookingConfigMultipleSelections: BookingServiceConfig;
80
- /**
81
- * Helper to create a service selection with custom instanceId
82
- */
83
- export declare function createMockServiceSelection(overrides?: Partial<ServiceSelection>): Omit<ServiceSelection, 'instanceId'>;
84
- /**
85
- * Helper to create multiple service selections
86
- */
87
- export declare function createMockServiceSelections(count: number): ServiceSelection[];
@@ -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
- }