Functional Weave
Code in Rust

charity.regular-giving-schedule@1.0.0

vectors.json

2,987 bytes · view raw

[
  {"name": "monthly on the 1st with 10 days' notice: October's date is too soon", "args": ["monthly", 1, "2026-09-23", 10, null, 3], "expect": ["2026-11-01", "2026-12-01", "2027-01-01"]},
  {"name": "monthly on the 31st clamps each month from the 31st, not from February's 28th", "args": ["monthly", 31, "2026-01-01", 0, null, 4], "expect": ["2026-01-31", "2026-02-28", "2026-03-31", "2026-04-30"]},
  {"name": "monthly on the 30th in a leap year gives 29 February", "args": ["monthly", 30, "2028-01-31", 0, null, 3], "expect": ["2028-02-29", "2028-03-30", "2028-04-30"]},
  {"name": "the sign-up day itself is the first collection when there is no lead time", "args": ["monthly", 23, "2026-09-23", 0, null, 2], "expect": ["2026-09-23", "2026-10-23"]},
  {"name": "quarterly on the 15th", "args": ["quarterly", 15, "2026-09-23", 5, null, 4], "expect": ["2026-10-15", "2027-01-15", "2027-04-15", "2027-07-15"]},
  {"name": "annually on 6 April", "args": ["annually", 6, "2026-04-01", 3, null, 3], "expect": ["2026-04-06", "2027-04-06", "2028-04-06"]},
  {"name": "annually on the 29th from February 2028: 28 February in ordinary years", "args": ["annually", 29, "2028-02-01", 0, null, 3], "expect": ["2028-02-29", "2029-02-28", "2030-02-28"]},
  {"name": "the lead time crosses a year end", "args": ["monthly", 5, "2026-12-25", 10, null, 2], "expect": ["2027-01-05", "2027-02-05"]},
  {"name": "an end date is inclusive and cuts the schedule short", "args": ["monthly", 1, "2026-09-01", 0, "2026-12-01", 12], "expect": ["2026-09-01", "2026-10-01", "2026-11-01", "2026-12-01"]},
  {"name": "an end date before the first possible collection gives nothing", "args": ["monthly", 1, "2026-09-23", 10, "2026-10-01", 12], "expect": []},
  {"name": "a count of zero is an empty schedule", "args": ["monthly", 1, "2026-09-23", 0, null, 0], "expect": []},
  {"name": "an unknown frequency is an error", "args": ["weekly", 1, "2026-09-23", 0, null, 3], "expectError": "unknown giving frequency \"weekly\""},
  {"name": "day 0 is an error", "args": ["monthly", 0, "2026-09-23", 0, null, 3], "expectError": "collectionDay must be 1-31"},
  {"name": "day 32 is an error", "args": ["monthly", 32, "2026-09-23", 0, null, 3], "expectError": "collectionDay must be 1-31"},
  {"name": "a fractional day is an error", "args": ["monthly", 1.5, "2026-09-23", 0, null, 3], "expectError": "collectionDay must be 1-31"},
  {"name": "negative lead days are an error", "args": ["monthly", 1, "2026-09-23", -1, null, 3], "expectError": "leadDays must not be negative"},
  {"name": "a negative count is an error", "args": ["monthly", 1, "2026-09-23", 0, null, -1], "expectError": "count must be a non-negative integer"},
  {"name": "a malformed sign-up date is an error", "args": ["monthly", 1, "23/09/2026", 0, null, 3], "expectError": "is not an ISO date"},
  {"name": "an impossible end date is an error", "args": ["monthly", 1, "2026-09-23", 0, "2026-02-30", 3], "expectError": "is not a real calendar date"}
]