Functional Weave
Code in TypeScript

energy.price-cap@1.0.2

vectors.json

4,696 bytes · view raw

[
  {"name": "electricity in May 2026: 24.67p/kWh and 57.21p a day", "args": ["electricity", "direct-debit", "2026-05-01"], "expect": {"fuel": "electricity", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 24670, "standingCharge": 57210, "vatBasisPoints": 500, "validFrom": "2026-04-01", "validTo": "2026-06-30"}},
  {"name": "gas in May 2026: 5.74p/kWh and 29.09p a day", "args": ["gas", "direct-debit", "2026-05-01"], "expect": {"fuel": "gas", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 5740, "standingCharge": 29090, "vatBasisPoints": 500, "validFrom": "2026-04-01", "validTo": "2026-06-30"}},
  {"name": "the first day of a cap period takes the new cap", "args": ["electricity", "direct-debit", "2025-04-01"], "expect": {"fuel": "electricity", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 27030, "standingCharge": 53800, "vatBasisPoints": 500, "validFrom": "2025-04-01", "validTo": "2025-06-30"}},
  {"name": "the last day of a cap period keeps the old one", "args": ["electricity", "direct-debit", "2025-03-31"], "expect": {"fuel": "electricity", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 24860, "standingCharge": 60970, "vatBasisPoints": 500, "validFrom": "2025-01-01", "validTo": "2025-03-31"}},
  {"name": "gas, July to September 2025", "args": ["gas", "direct-debit", "2025-08-15"], "expect": {"fuel": "gas", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 6330, "standingCharge": 29820, "vatBasisPoints": 500, "validFrom": "2025-07-01", "validTo": "2025-09-30"}},
  {"name": "gas standing charge jumps in October 2025", "args": ["gas", "direct-debit", "2025-10-01"], "expect": {"fuel": "gas", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 6290, "standingCharge": 34030, "vatBasisPoints": 500, "validFrom": "2025-10-01", "validTo": "2025-12-31"}},
  {"name": "electricity, January to March 2026", "args": ["electricity", "direct-debit", "2026-02-28"], "expect": {"fuel": "electricity", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 27690, "standingCharge": 54750, "vatBasisPoints": 500, "validFrom": "2026-01-01", "validTo": "2026-03-31"}},
  {"name": "electricity from 1 October 2026 carries no VAT", "args": ["electricity", "direct-debit", "2026-10-01"], "expect": {"fuel": "electricity", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 26320, "standingCharge": 54830, "vatBasisPoints": 0, "validFrom": "2026-10-01", "validTo": "2026-12-31"}},
  {"name": "gas from 1 October 2026 still includes 5% VAT", "args": ["gas", "direct-debit", "2026-12-31"], "expect": {"fuel": "gas", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 7970, "standingCharge": 29680, "vatBasisPoints": 500, "validFrom": "2026-10-01", "validTo": "2026-12-31"}},
  {"name": "the earliest period carried, October 2024", "args": ["gas", "direct-debit", "2024-10-01"], "expect": {"fuel": "gas", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 6240, "standingCharge": 31660, "vatBasisPoints": 500, "validFrom": "2024-10-01", "validTo": "2024-12-31"}},
  {"name": "electricity, July to September 2026", "args": ["electricity", "direct-debit", "2026-09-30"], "expect": {"fuel": "electricity", "paymentMethod": "direct-debit", "region": "GB", "unitRate": 26110, "standingCharge": 57190, "vatBasisPoints": 500, "validFrom": "2026-07-01", "validTo": "2026-09-30"}},
  {"name": "a period not yet announced is an error, not the latest cap", "args": ["electricity", "direct-debit", "2027-01-01"], "expectError": "no price cap for electricity/direct-debit on 2027-01-01"},
  {"name": "before the earliest period carried", "args": ["gas", "direct-debit", "2024-09-30"], "expectError": "no price cap for gas/direct-debit on 2024-09-30"},
  {"name": "prepayment figures are not carried", "args": ["electricity", "prepayment", "2026-05-01"], "expectError": "no price cap figures for electricity paid by prepayment"},
  {"name": "an unknown fuel", "args": ["oil", "direct-debit", "2026-05-01"], "expectError": "unknown fuel \"oil\""},
  {"name": "an unknown payment method", "args": ["gas", "cash", "2026-05-01"], "expectError": "unknown payment method \"cash\""},
  {"name": "a malformed date", "args": ["gas", "direct-debit", "2026-5-1"], "expectError": "onDate must be an ISO date"},
  {"name": "a onDate with a trailing newline is refused", "args": ["gas", "direct-debit", "2026-09-16\n"], "expectError": "onDate must be an ISO date (YYYY-MM-DD), received \"2026-09-16\n\""},
  {"name": "a onDate in Arabic-Indic digits is refused", "args": ["gas", "direct-debit", "٢٠٢٦-٠٩-١٦"], "expectError": "onDate must be an ISO date (YYYY-MM-DD), received \"٢٠٢٦-٠٩-١٦\""}
]