[ { "name": "a 2,500.00 loss less 250.00 compulsory and 250.00 voluntary excess pays 2,000.00", "args": [ { "minor": 250000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, null, false ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 200000, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 50000, "currency": "GBP" } } }, { "name": "a loss smaller than the excess pays nothing", "args": [ { "minor": 30000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, null, false ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 30000, "currency": "GBP" }, "payout": { "minor": 0, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 30000, "currency": "GBP" } } }, { "name": "a loss exactly the excess pays nothing", "args": [ { "minor": 50000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, null, false ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 0, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 50000, "currency": "GBP" } } }, { "name": "a zero loss", "args": [ { "minor": 0, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, null, false ], "expect": { "totalExcess": { "minor": 25000, "currency": "GBP" }, "excessApplied": { "minor": 0, "currency": "GBP" }, "payout": { "minor": 0, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 0, "currency": "GBP" } } }, { "name": "no excess pays the whole loss", "args": [ { "minor": 123456, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, null, false ], "expect": { "totalExcess": { "minor": 0, "currency": "GBP" }, "excessApplied": { "minor": 0, "currency": "GBP" }, "payout": { "minor": 123456, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 0, "currency": "GBP" } } }, { "name": "the limit caps the payout after the excess", "args": [ { "minor": 1200000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 1000000, "currency": "GBP" }, false ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 1000000, "currency": "GBP" }, "limitApplied": true, "uninsured": { "minor": 200000, "currency": "GBP" } } }, { "name": "with the excess within the limit it erodes the limit", "args": [ { "minor": 1200000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 25000, "currency": "GBP" }, { "minor": 1000000, "currency": "GBP" }, true ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 950000, "currency": "GBP" }, "limitApplied": true, "uninsured": { "minor": 250000, "currency": "GBP" } } }, { "name": "a loss just over the limit: after the excess it is under, so the limit does not bite", "args": [ { "minor": 1040000, "currency": "GBP" }, { "minor": 50000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 1000000, "currency": "GBP" }, false ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 990000, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 50000, "currency": "GBP" } } }, { "name": "the same loss with the excess within the limit: capped first, then the excess", "args": [ { "minor": 1040000, "currency": "GBP" }, { "minor": 50000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 1000000, "currency": "GBP" }, true ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 950000, "currency": "GBP" }, "limitApplied": true, "uninsured": { "minor": 90000, "currency": "GBP" } } }, { "name": "well under the limit, the limit changes nothing", "args": [ { "minor": 500000, "currency": "GBP" }, { "minor": 10000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 1000000, "currency": "GBP" }, false ], "expect": { "totalExcess": { "minor": 10000, "currency": "GBP" }, "excessApplied": { "minor": 10000, "currency": "GBP" }, "payout": { "minor": 490000, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 10000, "currency": "GBP" } } }, { "name": "a limit of zero pays nothing", "args": [ { "minor": 500000, "currency": "GBP" }, { "minor": 10000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, false ], "expect": { "totalExcess": { "minor": 10000, "currency": "GBP" }, "excessApplied": { "minor": 10000, "currency": "GBP" }, "payout": { "minor": 0, "currency": "GBP" }, "limitApplied": true, "uninsured": { "minor": 500000, "currency": "GBP" } } }, { "name": "payout exactly the limit is not reduced by it", "args": [ { "minor": 1050000, "currency": "GBP" }, { "minor": 50000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 1000000, "currency": "GBP" }, false ], "expect": { "totalExcess": { "minor": 50000, "currency": "GBP" }, "excessApplied": { "minor": 50000, "currency": "GBP" }, "payout": { "minor": 1000000, "currency": "GBP" }, "limitApplied": false, "uninsured": { "minor": 50000, "currency": "GBP" } } }, { "name": "a negative loss is refused", "args": [ { "minor": -1, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, null, false ], "expectError": "loss must not be negative" }, { "name": "a negative excess is refused", "args": [ { "minor": 1000, "currency": "GBP" }, { "minor": -100, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, null, false ], "expectError": "excess must not be negative" }, { "name": "a negative limit is refused", "args": [ { "minor": 1000, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": 0, "currency": "GBP" }, { "minor": -5, "currency": "GBP" }, false ], "expectError": "policyLimit must not be negative" }, { "name": "an excess in another currency is refused", "args": [ { "minor": 1000, "currency": "GBP" }, { "minor": 100, "currency": "EUR" }, { "minor": 0, "currency": "GBP" }, null, false ], "expectError": "currency mismatch" } ]