mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 00:27:55 +00:00
Revert: Update test.js
This commit is contained in:
@@ -7,7 +7,10 @@ export default {
|
|||||||
// - You MUST use a dynamic import() to load one or more libraries from a CDN for date/time manipulation.
|
// - You MUST use a dynamic import() to load one or more libraries from a CDN for date/time manipulation.
|
||||||
// - The function should find all non-overlapping time slots of 'durationMinutes' where both parties are free, within their working hours, and within the search range.
|
// - The function should find all non-overlapping time slots of 'durationMinutes' where both parties are free, within their working hours, and within the search range.
|
||||||
// - Return an array of available slots, each as an object: { start: 'ISODateString', end: 'ISODateString' }`,
|
// - Return an array of available slots, each as an object: { start: 'ISODateString', end: 'ISODateString' }`,
|
||||||
getTestCases: () => {
|
runTest: async (findAvailableSlots) => {
|
||||||
|
const assert = {
|
||||||
|
deepStrictEqual: (a, e, m) => { if (JSON.stringify(a) !== JSON.stringify(e)) throw new Error(m || `FAIL: ${JSON.stringify(a)} !== ${JSON.stringify(e)}`) },
|
||||||
|
};
|
||||||
const today = new Date().toISOString().split('T')[0];
|
const today = new Date().toISOString().split('T')[0];
|
||||||
const calendar1 = [
|
const calendar1 = [
|
||||||
{ start: `${today}T09:00:00.000Z`, end: `${today}T10:30:00.000Z` },
|
{ start: `${today}T09:00:00.000Z`, end: `${today}T10:30:00.000Z` },
|
||||||
@@ -22,21 +25,16 @@ export default {
|
|||||||
searchRange: { start: `${today}T00:00:00.000Z`, end: `${today}T23:59:59.999Z` },
|
searchRange: { start: `${today}T00:00:00.000Z`, end: `${today}T23:59:59.999Z` },
|
||||||
workHours: { start: '09:00', end: '17:00' }
|
workHours: { start: '09:00', end: '17:00' }
|
||||||
};
|
};
|
||||||
return [calendar1, calendar2, constraints];
|
|
||||||
},
|
|
||||||
runTest: async (findAvailableSlots) => {
|
|
||||||
const assert = {
|
|
||||||
deepStrictEqual: (a, e, m) => { if (JSON.stringify(a) !== JSON.stringify(e)) throw new Error(m || `FAIL: ${JSON.stringify(a)} !== ${JSON.stringify(e)}`) },
|
|
||||||
};
|
|
||||||
const [calendar1, calendar2, constraints] = globalThis.getTestCases ? globalThis.getTestCases() : this.getTestCases();
|
|
||||||
const today = new Date().toISOString().split('T')[0];
|
|
||||||
const expected = [
|
const expected = [
|
||||||
{ start: `${today}T11:00:00.000Z`, end: `${today}T12:00:00.000Z` },
|
{ start: `${today}T11:00:00.000Z`, end: `${today}T12:00:00.000Z` },
|
||||||
{ start: `${today}T13:00:00.000Z`, end: `${today}T14:00:00.000Z` },
|
{ start: `${today}T13:00:00.000Z`, end: `${today}T14:00:00.000Z` },
|
||||||
{ start: `${today}T14:30:00.000Z`, end: `${today}T15:30:00.000Z` },
|
{ start: `${today}T14:30:00.000Z`, end: `${today}T15:30:00.000Z` },
|
||||||
{ start: `${today}T15:30:00.000Z`, end: `${today}T16:30:00.000Z` },
|
{ start: `${today}T15:30:00.000Z`, end: `${today}T16:30:00.000Z` },
|
||||||
];
|
];
|
||||||
|
|
||||||
const result = await findAvailableSlots(calendar1, calendar2, constraints);
|
const result = await findAvailableSlots(calendar1, calendar2, constraints);
|
||||||
assert.deepStrictEqual(result, expected, 'Test Failed: Incorrect slots found.');
|
assert.deepStrictEqual(result, expected, 'Test Failed: Incorrect slots found.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user