@happychef/algorithm 1.2.8 → 1.2.10

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.
@@ -0,0 +1,103 @@
1
+ name: CI/CD Pipeline
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ branches:
9
+ - main
10
+
11
+ jobs:
12
+ test:
13
+ name: Run Tests
14
+ runs-on: ubuntu-latest
15
+
16
+ strategy:
17
+ matrix:
18
+ node-version: [18.x, 20.x]
19
+
20
+ steps:
21
+ - name: Checkout code
22
+ uses: actions/checkout@v4
23
+
24
+ - name: Setup Node.js ${{ matrix.node-version }}
25
+ uses: actions/setup-node@v4
26
+ with:
27
+ node-version: ${{ matrix.node-version }}
28
+ cache: 'npm'
29
+
30
+ - name: Install dependencies
31
+ run: npm ci
32
+
33
+ - name: Run tests
34
+ run: npm test
35
+
36
+ - name: Run tests with coverage
37
+ run: npm run test:coverage
38
+
39
+ - name: Upload coverage reports
40
+ uses: codecov/codecov-action@v4
41
+ if: matrix.node-version == '20.x'
42
+ with:
43
+ files: ./coverage/lcov.info
44
+ flags: unittests
45
+ name: codecov-umbrella
46
+ fail_ci_if_error: false
47
+ env:
48
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49
+
50
+ publish:
51
+ name: Publish to NPM
52
+ needs: test
53
+ runs-on: ubuntu-latest
54
+ if: github.ref == 'refs/heads/main' && github.event_name == 'push'
55
+
56
+ steps:
57
+ - name: Checkout code
58
+ uses: actions/checkout@v4
59
+
60
+ - name: Setup Node.js
61
+ uses: actions/setup-node@v4
62
+ with:
63
+ node-version: '20.x'
64
+ registry-url: 'https://registry.npmjs.org'
65
+ cache: 'npm'
66
+
67
+ - name: Install dependencies
68
+ run: npm ci
69
+
70
+ - name: Run tests
71
+ run: npm test
72
+
73
+ - name: Check if version changed
74
+ id: version-check
75
+ run: |
76
+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
77
+ NPM_VERSION=$(npm view @happychef/algorithm version 2>/dev/null || echo "0.0.0")
78
+ echo "Package version: $PACKAGE_VERSION"
79
+ echo "NPM version: $NPM_VERSION"
80
+ if [ "$PACKAGE_VERSION" != "$NPM_VERSION" ]; then
81
+ echo "version_changed=true" >> $GITHUB_OUTPUT
82
+ echo "Version changed from $NPM_VERSION to $PACKAGE_VERSION"
83
+ else
84
+ echo "version_changed=false" >> $GITHUB_OUTPUT
85
+ echo "Version unchanged: $PACKAGE_VERSION"
86
+ fi
87
+
88
+ - name: Publish to NPM
89
+ if: steps.version-check.outputs.version_changed == 'true'
90
+ run: npm publish --access public
91
+ env:
92
+ NODE_AUTH_TOKEN: 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
93
+
94
+ - name: Create Git Tag
95
+ if: steps.version-check.outputs.version_changed == 'true'
96
+ run: |
97
+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
98
+ git config user.name "github-actions[bot]"
99
+ git config user.email "github-actions[bot]@users.noreply.github.com"
100
+ git tag -a "v$PACKAGE_VERSION" -m "Release v$PACKAGE_VERSION"
101
+ git push origin "v$PACKAGE_VERSION"
102
+ env:
103
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # @happychef/algorithm
2
+
3
+ Restaurant and reservation algorithm utilities for Happy Chef.
4
+
5
+ [![CI/CD Pipeline](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/YOUR_USERNAME/YOUR_REPO/actions/workflows/ci-cd.yml)
6
+ [![codecov](https://codecov.io/gh/YOUR_USERNAME/YOUR_REPO/branch/main/graph/badge.svg)](https://codecov.io/gh/YOUR_USERNAME/YOUR_REPO)
7
+ [![npm version](https://badge.fury.io/js/%40happychef%2Falgorithm.svg)](https://www.npmjs.com/package/@happychef/algorithm)
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @happychef/algorithm
13
+ ```
14
+
15
+ ## Features
16
+
17
+ - **Date & Time Availability**: Check if specific dates and times are available for reservations
18
+ - **Timeblock Management**: Get available timeblocks based on restaurant settings
19
+ - **Table Assignment**: Automatically assign tables to reservations
20
+ - **Smart Filtering**: Filter timeblocks based on max arrivals, max groups, and other constraints
21
+ - **Exception Handling**: Support for restaurant opening hours exceptions and closures
22
+ - **Comprehensive Testing**: 70+ unit tests ensuring reliability
23
+
24
+ ## Usage
25
+
26
+ ```javascript
27
+ const {
28
+ isDateAvailable,
29
+ isTimeAvailable,
30
+ getAvailableTimeblocks,
31
+ assignTablesIfPossible
32
+ } = require('@happychef/algorithm');
33
+
34
+ // Check if a date is available
35
+ const available = isDateAvailable(
36
+ restaurantData,
37
+ '2025-06-15',
38
+ reservations,
39
+ guests
40
+ );
41
+
42
+ // Get available timeblocks
43
+ const timeblocks = getAvailableTimeblocks(
44
+ restaurantData,
45
+ '2025-06-15',
46
+ reservations,
47
+ guests
48
+ );
49
+
50
+ // Check if specific time is available
51
+ const timeAvailable = isTimeAvailable(
52
+ restaurantData,
53
+ '2025-06-15',
54
+ '12:00',
55
+ reservations,
56
+ guests
57
+ );
58
+ ```
59
+
60
+ ## Development
61
+
62
+ ### Running Tests
63
+
64
+ ```bash
65
+ # Run all tests
66
+ npm test
67
+
68
+ # Run tests in watch mode
69
+ npm run test:watch
70
+
71
+ # Run tests with coverage
72
+ npm run test:coverage
73
+ ```
74
+
75
+ ### Test Coverage
76
+
77
+ The package includes comprehensive unit tests covering:
78
+ - Helper functions (parseTime, getMealTypeByTime, etc.)
79
+ - Date and time availability checks
80
+ - Timeblock filtering
81
+ - Restaurant data and exceptions handling
82
+ - Table assignment logic
83
+ - Filter functions (max arrivals, max groups)
84
+
85
+ All tests are automatically run on every push to the main branch via GitHub Actions.
86
+
87
+ ## CI/CD Pipeline
88
+
89
+ This package uses GitHub Actions for continuous integration and deployment:
90
+
91
+ 1. **Automated Testing**: Tests run on Node.js 18.x and 20.x
92
+ 2. **Coverage Reports**: Automatically uploaded to Codecov
93
+ 3. **Automatic Publishing**: When tests pass on main branch and version changes, package is automatically published to npm
94
+ 4. **Git Tagging**: Successful releases are automatically tagged
95
+
96
+ ### Setup Instructions
97
+
98
+ To enable automatic publishing:
99
+
100
+ 1. **Create an NPM Token**:
101
+ - Go to [npmjs.com](https://www.npmjs.com/)
102
+ - Navigate to Access Tokens
103
+ - Generate a new "Automation" token
104
+ - Copy the token
105
+
106
+ 2. **Add NPM Token to GitHub Secrets**:
107
+ - Go to your GitHub repository
108
+ - Navigate to Settings > Secrets and variables > Actions
109
+ - Click "New repository secret"
110
+ - Name: `NPM_TOKEN`
111
+ - Value: Paste your NPM token
112
+ - Click "Add secret"
113
+
114
+ 3. **Optional: Add Codecov Token** (for coverage reports):
115
+ - Go to [codecov.io](https://codecov.io/)
116
+ - Add your repository
117
+ - Copy the token
118
+ - Add as `CODECOV_TOKEN` secret in GitHub
119
+
120
+ 4. **Publish New Version**:
121
+ - Update version in `package.json`
122
+ - Commit and push to main branch
123
+ - GitHub Actions will automatically:
124
+ - Run all tests
125
+ - Publish to npm if tests pass
126
+ - Create a git tag for the release
127
+
128
+ ## Contributing
129
+
130
+ 1. Fork the repository
131
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
132
+ 3. Write tests for your changes
133
+ 4. Ensure all tests pass (`npm test`)
134
+ 5. Commit your changes (`git commit -m 'Add some amazing feature'`)
135
+ 6. Push to the branch (`git push origin feature/amazing-feature`)
136
+ 7. Open a Pull Request
137
+
138
+ ## License
139
+
140
+ MIT
141
+
142
+ ## Author
143
+
144
+ Happy Chef
@@ -0,0 +1,276 @@
1
+ const { filterTimeblocksByMaxArrivals } = require('../filters/maxArrivalsFilter');
2
+ const { filterTimeblocksByMaxGroups } = require('../filters/maxGroupsFilter');
3
+
4
+ describe('maxArrivalsFilter', () => {
5
+ test('should keep timeblocks when no max arrivals config exists', () => {
6
+ const restaurantData = {};
7
+ const timeblocks = {
8
+ '12:00': { name: '12:00' },
9
+ '12:30': { name: '12:30' }
10
+ };
11
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, [], 4);
12
+ expect(result).toEqual(timeblocks);
13
+ });
14
+
15
+ test('should filter out timeblocks that exceed max arrivals', () => {
16
+ const restaurantData = {
17
+ 'max-arrivals-lunch': {
18
+ '12:00': 10,
19
+ '12:30': 8
20
+ }
21
+ };
22
+ const timeblocks = {
23
+ '12:00': { name: '12:00' },
24
+ '12:30': { name: '12:30' }
25
+ };
26
+ const reservations = [
27
+ { date: '2025-06-15', time: '12:00', guests: 8 }
28
+ ];
29
+
30
+ // Adding 4 guests to 12:00 (8 + 4 = 12 > 10) should filter it out
31
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, reservations, 4);
32
+ expect(result['12:00']).toBeUndefined();
33
+ expect(result['12:30']).toBeDefined();
34
+ });
35
+
36
+ test('should keep timeblocks when within max arrivals limit', () => {
37
+ const restaurantData = {
38
+ 'max-arrivals-lunch': {
39
+ '12:00': 20
40
+ }
41
+ };
42
+ const timeblocks = {
43
+ '12:00': { name: '12:00' }
44
+ };
45
+ const reservations = [
46
+ { date: '2025-06-15', time: '12:00', guests: 10 }
47
+ ];
48
+
49
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, reservations, 5);
50
+ expect(result['12:00']).toBeDefined();
51
+ });
52
+
53
+ test('should handle MongoDB NumberInt format', () => {
54
+ const restaurantData = {
55
+ 'max-arrivals-lunch': {
56
+ '12:00': { $numberInt: '20' }
57
+ }
58
+ };
59
+ const timeblocks = {
60
+ '12:00': { name: '12:00' }
61
+ };
62
+ const reservations = [
63
+ { date: '2025-06-15', time: '12:00', guests: 15 }
64
+ ];
65
+
66
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, reservations, 5);
67
+ expect(result['12:00']).toBeDefined();
68
+ });
69
+
70
+ test('should handle breakfast times correctly', () => {
71
+ const restaurantData = {
72
+ 'max-arrivals-breakfast': {
73
+ '09:00': 15
74
+ }
75
+ };
76
+ const timeblocks = {
77
+ '09:00': { name: '09:00' }
78
+ };
79
+ const reservations = [
80
+ { date: '2025-06-15', time: '09:00', guests: 12 }
81
+ ];
82
+
83
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, reservations, 2);
84
+ expect(result['09:00']).toBeDefined();
85
+ });
86
+
87
+ test('should handle dinner times correctly', () => {
88
+ const restaurantData = {
89
+ 'max-arrivals-dinner': {
90
+ '18:00': 30
91
+ }
92
+ };
93
+ const timeblocks = {
94
+ '18:00': { name: '18:00' }
95
+ };
96
+ const reservations = [
97
+ { date: '2025-06-15', time: '18:00', guests: 20 }
98
+ ];
99
+
100
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, reservations, 5);
101
+ expect(result['18:00']).toBeDefined();
102
+ });
103
+
104
+ test('should only count arrivals on the specific date', () => {
105
+ const restaurantData = {
106
+ 'max-arrivals-lunch': {
107
+ '12:00': 10
108
+ }
109
+ };
110
+ const timeblocks = {
111
+ '12:00': { name: '12:00' }
112
+ };
113
+ const reservations = [
114
+ { date: '2025-06-14', time: '12:00', guests: 8 }, // Different date
115
+ { date: '2025-06-15', time: '12:00', guests: 2 }
116
+ ];
117
+
118
+ const result = filterTimeblocksByMaxArrivals(restaurantData, '2025-06-15', timeblocks, reservations, 5);
119
+ expect(result['12:00']).toBeDefined(); // 2 + 5 = 7 <= 10
120
+ });
121
+ });
122
+
123
+ describe('maxGroupsFilter', () => {
124
+ test('should keep timeblocks when no max groups config exists', () => {
125
+ const restaurantData = {};
126
+ const timeblocks = {
127
+ '12:00': { name: '12:00' },
128
+ '12:30': { name: '12:30' }
129
+ };
130
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, [], 4);
131
+ expect(result).toEqual(timeblocks);
132
+ });
133
+
134
+ test('should filter out timeblocks that exceed max groups for a size threshold', () => {
135
+ const restaurantData = {
136
+ 'max-groups-lunch': {
137
+ '6': 2 // Max 2 groups of 6+ people
138
+ }
139
+ };
140
+ const timeblocks = {
141
+ '12:00': { name: '12:00' },
142
+ '13:00': { name: '13:00' }
143
+ };
144
+ const reservations = [
145
+ { date: '2025-06-15', time: '12:00', guests: 7 },
146
+ { date: '2025-06-15', time: '12:30', guests: 8 }
147
+ ];
148
+
149
+ // Already have 2 groups of 6+, so adding another should be blocked
150
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 6);
151
+ expect(Object.keys(result)).toHaveLength(0);
152
+ });
153
+
154
+ test('should keep timeblocks when within max groups limit', () => {
155
+ const restaurantData = {
156
+ 'max-groups-lunch': {
157
+ '6': 3 // Max 3 groups of 6+ people
158
+ }
159
+ };
160
+ const timeblocks = {
161
+ '12:00': { name: '12:00' }
162
+ };
163
+ const reservations = [
164
+ { date: '2025-06-15', time: '12:00', guests: 7 }
165
+ ];
166
+
167
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 6);
168
+ expect(result['12:00']).toBeDefined(); // 1 + 1 = 2 <= 3
169
+ });
170
+
171
+ test('should not apply filter if new booking is smaller than threshold', () => {
172
+ const restaurantData = {
173
+ 'max-groups-lunch': {
174
+ '6': 1 // Max 1 group of 6+ people
175
+ }
176
+ };
177
+ const timeblocks = {
178
+ '12:00': { name: '12:00' }
179
+ };
180
+ const reservations = [
181
+ { date: '2025-06-15', time: '12:00', guests: 8 }
182
+ ];
183
+
184
+ // Booking for 4 people - doesn't meet the 6+ threshold
185
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 4);
186
+ expect(result['12:00']).toBeDefined();
187
+ });
188
+
189
+ test('should handle MongoDB NumberInt format', () => {
190
+ const restaurantData = {
191
+ 'max-groups-lunch': {
192
+ '6': { $numberInt: '2' }
193
+ }
194
+ };
195
+ const timeblocks = {
196
+ '12:00': { name: '12:00' }
197
+ };
198
+ const reservations = [
199
+ { date: '2025-06-15', time: '12:00', guests: 7 }
200
+ ];
201
+
202
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 6);
203
+ expect(result['12:00']).toBeDefined();
204
+ });
205
+
206
+ test('should handle multiple thresholds correctly', () => {
207
+ const restaurantData = {
208
+ 'max-groups-lunch': {
209
+ '6': 2,
210
+ '10': 1
211
+ }
212
+ };
213
+ const timeblocks = {
214
+ '12:00': { name: '12:00' }
215
+ };
216
+ const reservations = [
217
+ { date: '2025-06-15', time: '12:00', guests: 12 } // Already have 1 group of 10+
218
+ ];
219
+
220
+ // Trying to add another 10+ group should be blocked
221
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 10);
222
+ expect(Object.keys(result)).toHaveLength(0);
223
+ });
224
+
225
+ test('should only count reservations for the same meal type', () => {
226
+ const restaurantData = {
227
+ 'max-groups-lunch': {
228
+ '6': 1
229
+ },
230
+ 'max-groups-dinner': {
231
+ '6': 1
232
+ }
233
+ };
234
+ const timeblocks = {
235
+ '12:00': { name: '12:00' } // lunch
236
+ };
237
+ const reservations = [
238
+ { date: '2025-06-15', time: '18:00', guests: 8 } // dinner - different meal type
239
+ ];
240
+
241
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 7);
242
+ expect(result['12:00']).toBeDefined(); // Dinner reservation doesn't count for lunch
243
+ });
244
+
245
+ test('should handle breakfast times correctly', () => {
246
+ const restaurantData = {
247
+ 'max-groups-breakfast': {
248
+ '4': 3
249
+ }
250
+ };
251
+ const timeblocks = {
252
+ '09:00': { name: '09:00' }
253
+ };
254
+ const reservations = [
255
+ { date: '2025-06-15', time: '08:00', guests: 5 },
256
+ { date: '2025-06-15', time: '09:30', guests: 4 }
257
+ ];
258
+
259
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, reservations, 6);
260
+ expect(result['09:00']).toBeDefined();
261
+ });
262
+
263
+ test('should handle invalid guest counts gracefully', () => {
264
+ const restaurantData = {
265
+ 'max-groups-lunch': {
266
+ '6': 2
267
+ }
268
+ };
269
+ const timeblocks = {
270
+ '12:00': { name: '12:00' }
271
+ };
272
+
273
+ const result = filterTimeblocksByMaxGroups(restaurantData, '2025-06-15', timeblocks, [], 'invalid');
274
+ expect(result).toEqual(timeblocks); // Should return unfiltered
275
+ });
276
+ });
@@ -0,0 +1,175 @@
1
+ const { isDateAvailable } = require('../isDateAvailable');
2
+
3
+ // Mock the getAvailableTimeblocks function
4
+ jest.mock('../getAvailableTimeblocks', () => ({
5
+ getAvailableTimeblocks: jest.fn()
6
+ }));
7
+
8
+ const { getAvailableTimeblocks } = require('../getAvailableTimeblocks');
9
+
10
+ describe('isDateAvailable', () => {
11
+ beforeEach(() => {
12
+ jest.clearAllMocks();
13
+ });
14
+
15
+ test('should return true when timeblocks are available', () => {
16
+ getAvailableTimeblocks.mockReturnValue({
17
+ '12:00': { name: '12:00' },
18
+ '12:30': { name: '12:30' }
19
+ });
20
+
21
+ const data = {
22
+ 'general-settings': {
23
+ dagenInToekomst: 90
24
+ }
25
+ };
26
+
27
+ const result = isDateAvailable(data, '2025-06-15', [], 4, [], null, false);
28
+ expect(result).toBe(true);
29
+ expect(getAvailableTimeblocks).toHaveBeenCalledWith(
30
+ data,
31
+ '2025-06-15',
32
+ [],
33
+ 4,
34
+ [],
35
+ null,
36
+ false
37
+ );
38
+ });
39
+
40
+ test('should return false when no timeblocks are available', () => {
41
+ getAvailableTimeblocks.mockReturnValue({});
42
+
43
+ const data = {
44
+ 'general-settings': {
45
+ dagenInToekomst: 90
46
+ }
47
+ };
48
+
49
+ const result = isDateAvailable(data, '2025-06-15', [], 4);
50
+ expect(result).toBe(false);
51
+ });
52
+
53
+ test('should return false when date is outside allowed range (non-admin)', () => {
54
+ getAvailableTimeblocks.mockReturnValue({});
55
+
56
+ const data = {
57
+ 'general-settings': {
58
+ dagenInToekomst: 1 // Only 1 day in future
59
+ }
60
+ };
61
+
62
+ // Use a date far in the future - the function will calculate if it's out of range
63
+ const result = isDateAvailable(data, '2099-12-31', [], 4, [], null, false);
64
+ expect(result).toBe(false);
65
+ });
66
+
67
+ test('should allow dates outside range when isAdmin is true', () => {
68
+ getAvailableTimeblocks.mockReturnValue({
69
+ '12:00': { name: '12:00' }
70
+ });
71
+
72
+ const data = {
73
+ 'general-settings': {
74
+ dagenInToekomst: 1
75
+ }
76
+ };
77
+
78
+ const result = isDateAvailable(data, '2099-12-31', [], 4, [], null, true);
79
+ expect(result).toBe(true);
80
+ });
81
+
82
+ test('should use default dagenInToekomst of 90 when not specified', () => {
83
+ getAvailableTimeblocks.mockReturnValue({
84
+ '12:00': { name: '12:00' }
85
+ });
86
+
87
+ const data = {
88
+ 'general-settings': {}
89
+ };
90
+
91
+ // Use a reasonable date within 90 days
92
+ const result = isDateAvailable(data, '2025-02-01', [], 4);
93
+ expect(result).toBe(true);
94
+ });
95
+
96
+ test('should handle giftcard parameter', () => {
97
+ getAvailableTimeblocks.mockReturnValue({
98
+ '12:00': { name: '12:00' }
99
+ });
100
+
101
+ const data = {
102
+ 'general-settings': {
103
+ dagenInToekomst: 90
104
+ }
105
+ };
106
+
107
+ const result = isDateAvailable(data, '2025-02-01', [], 4, [], 'LUNCH50');
108
+ expect(result).toBe(true);
109
+ expect(getAvailableTimeblocks).toHaveBeenCalledWith(
110
+ data,
111
+ '2025-02-01',
112
+ [],
113
+ 4,
114
+ [],
115
+ 'LUNCH50',
116
+ false
117
+ );
118
+ });
119
+
120
+ test('should handle blockedSlots parameter', () => {
121
+ getAvailableTimeblocks.mockReturnValue({
122
+ '12:00': { name: '12:00' }
123
+ });
124
+
125
+ const data = {
126
+ 'general-settings': {
127
+ dagenInToekomst: 90
128
+ }
129
+ };
130
+
131
+ const blockedSlots = [
132
+ { date: '2025-02-01', time: '13:00' }
133
+ ];
134
+
135
+ const result = isDateAvailable(data, '2025-02-01', [], 4, blockedSlots);
136
+ expect(result).toBe(true);
137
+ expect(getAvailableTimeblocks).toHaveBeenCalledWith(
138
+ data,
139
+ '2025-02-01',
140
+ [],
141
+ 4,
142
+ blockedSlots,
143
+ null,
144
+ false
145
+ );
146
+ });
147
+
148
+ test('should handle reservations array', () => {
149
+ getAvailableTimeblocks.mockReturnValue({
150
+ '12:00': { name: '12:00' }
151
+ });
152
+
153
+ const data = {
154
+ 'general-settings': {
155
+ dagenInToekomst: 90
156
+ }
157
+ };
158
+
159
+ const reservations = [
160
+ { date: '2025-02-01', time: '12:00', guests: 2 }
161
+ ];
162
+
163
+ const result = isDateAvailable(data, '2025-02-01', reservations, 4);
164
+ expect(result).toBe(true);
165
+ expect(getAvailableTimeblocks).toHaveBeenCalledWith(
166
+ data,
167
+ '2025-02-01',
168
+ reservations,
169
+ 4,
170
+ [],
171
+ null,
172
+ false
173
+ );
174
+ });
175
+ });