Test cases
The calculation engine is locked behind an automated test suite. Every check below runs against the real calculator before any change is accepted, so the results you see in the app match the figures listed here. All 158 tests currently pass.
158 of 158 tests shown
Core fara'id engine & exact fractions
The foundation: exact fractional arithmetic, spouse and children shares, parents and grandparents, siblings, the 'awl and radd correction rules, and money handling (debts, funeral costs, bequests).
29 tests · src/lib/inheritance.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Fractions reduce to lowest terms | 2/4 → 1/2; 6/9 → 2/3 | Passing |
| Fraction arithmetic is exact | 1/2 + 1/3 = 5/6; 1/2 − 1/3 = 1/6; 2/3 × 3/4 = 1/2; 1/2 ÷ 1/4 = 2 | Passing |
| Negative denominators are normalised | 1/−2 → −1/2 | Passing |
| Division by zero throws | Fraction(1, 0) raises an error | Passing |
| Husband gets 1/2 without children, 1/4 with children | No children: Husband 1/2. With a son: Husband 1/4 | Passing |
| Wife gets 1/4 without children, 1/8 with children | No children: Wife 1/4. With a son: Wife 1/8 | Passing |
| Multiple wives share the wife portion equally | Two wives with a son: 1/16 each | Passing |
| Sons and daughters share the residue 2:1 | Wife 1/8; each son 7/20; daughter 7/40; total exactly 1 | Passing |
| A single daughter takes 1/2, two or more share 2/3 (radd tops up when alone) | With wife: daughter 7/8 after radd; three daughters 7/24 each; alone: daughter takes the whole estate | Passing |
| Daughters become residuary with sons instead of fixed-share heirs | Daughter's basis reads “Residuary” when a son is present | Passing |
| Mother gets 1/3 without children or 2+ siblings, 1/6 otherwise | With wife only: mother 3/4 after radd; with a son or two brothers: 1/6 | Passing |
| Father takes 1/6 plus residue when children exist | With a daughter: father totals 1/2 (1/6 fixed + 1/3 residue); total exactly 1 | Passing |
| Father is the residuary when there are no children | Wife 1/4; Father 3/4 | Passing |
| Grandfather substitutes for a deceased father | Wife 1/4; Grandfather 3/4 | Passing |
| Maternal grandmother takes her own 1/6 when mother is absent | With a son: maternal grandmother 1/6 | Passing |
| Siblings inherit only when there are no children and no male ascendant | A living father or son blocks full brothers; a blocking note is shown | Passing |
| Full brothers and sisters share the residue 2:1 | Wife 1/4; full brother 1/2; full sister 1/4; total exactly 1 | Passing |
| A single full sister takes 1/2, two or more share 2/3 (radd tops up when alone) | With husband: sister 1/2; two sisters with husband: 2/7 each after 'awl; alone: whole estate | Passing |
| Paternal siblings inherit only when there are no full siblings | A full brother blocks paternal brothers; alone, a paternal brother takes the whole estate | Passing |
| Maternal siblings take 1/6 singly or 1/3 shared (radd tops up when alone) | One: 1/6; two: 1/6 each; alone: whole estate by radd | Passing |
| Applies 'awl when fixed shares exceed the estate | Wife 1/9, father 4/27, mother 4/27, each daughter 8/27; total exactly 1 | Passing |
| Applies radd to non-spouse heirs when there is no residuary | Wife keeps 1/4 (spouses excluded from radd); mother rises to 3/4 | Passing |
| Leaves surplus to bayt al-mal when only a spouse remains | Wife 1/4; the explanation names the public treasury (bayt al-mal) | Passing |
| Reports exact when shares fill the estate precisely | Husband 1/2 + mother 1/3 + maternal sibling 1/6 = exactly 1; rule “exact” | Passing |
| Returns rule 'none' when no heirs are entered | No heirs listed; rule “none” | Passing |
| Deducts debts and funeral costs before distribution | 100,000 − 20,000 debts − 10,000 funeral = 70,000 net to the son | Passing |
| Caps the bequest at one third of the estate after debts | 60,000 bequest on 90,000 is capped to 30,000; a note explains the cap | Passing |
| Applies the bequest in full when within one third | 20,000 bequest on 90,000 applied in full; net 70,000 | Passing |
| Never lets the net estate go below zero | Debts of 5,000 on a 1,000 estate: net 0, heir amount 0 | Passing |
Differences between the four schools
The cases where Hanafi, Maliki, Shafi'i and Hanbali rulings diverge: the 'Umariyyatayn, grandfather with siblings, radd versus the treasury, the mushtaraka, and the school-comparison view.
15 tests · src/lib/inheritance.madhab.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| 'Umariyyatayn — husband + mother + father: mother gets 1/6 | Husband 1/2; Mother 1/6 (third of the remainder); Father 1/3 | Passing |
| 'Umariyyatayn — wife + mother + father: mother gets 1/4 | Wife 1/4; Mother 1/4; Father 1/2 | Passing |
| Hanafi: grandfather blocks siblings | Grandfather takes the whole estate; siblings shown as blocked by him | Passing |
| Shafi'i: grandfather shares with siblings (muqasama) | Grandfather 1/3; each full brother 1/3; total exactly 1 | Passing |
| Grandfather takes 1/3 of the residue when better than sharing | With three brothers: grandfather 1/3; each brother 2/9 | Passing |
| Maliki sends surplus to the treasury | One daughter: daughter 1/2; bayt al-mal 1/2; rule “baytalmal” | Passing |
| Hanbali returns the surplus (radd) | One daughter: daughter takes the whole estate | Passing |
| Mushtaraka — Hanafi: full brother gets nothing and is flagged | Full brother excluded and listed as blocked | Passing |
| Mushtaraka — Shafi'i: full brother shares the 1/3 | Full brother 1/9; each maternal sibling 1/9; total exactly 1 | Passing |
| Full brother takes residue after a daughter | Daughter 1/2; full brother 1/2 | Passing |
| Full sister is residuary alongside daughters | Two daughters + full sister: sister 1/3 | Passing |
| Paternal sister gets 1/6 with one full sister | Paternal sister receives her completing sixth | Passing |
| Blocked list names siblings blocked by a son and grandmother by mother | Lists “Full siblings (2)”, “Maternal sibling”, and “Maternal grandmother (mother's mother)” | Passing |
| compareSchools returns null when schools agree | Wife + son: no divergence reported | Passing |
| compareSchools reports divergence for grandfather + siblings | First topic title mentions the grandfather | Passing |
Paternal uncles
Paternal uncles as residuary heirs: who blocks them, how they split the residue, and confirmation that all four schools agree on these outcomes.
13 tests · src/lib/inheritance.uncles.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| A sole paternal uncle takes the whole estate | Paternal uncle 1; rule “asaba”; total exactly 1 | Passing |
| Multiple full uncles split the residue equally | Three uncles: 1/3 each; total exactly 1 | Passing |
| Full uncles block the father's paternal half-brothers | Full uncle takes all; half-uncles listed as blocked | Passing |
| Paternal half-uncles inherit when there are no full uncles | Two half-uncles: 1/2 each | Passing |
| A son blocks uncles | Uncle receives nothing; blocked by “Son” | Passing |
| The father blocks uncles | Uncle receives nothing; blocked by “Father” | Passing |
| The grandfather blocks uncles | Uncle receives nothing; blocked by “Grandfather” | Passing |
| A full brother blocks uncles | Uncle receives nothing; blocked by “Full brother” | Passing |
| A paternal brother blocks uncles | Uncle receives nothing; blocked by “Paternal brother” | Passing |
| Wife + mother + uncle: uncle takes the residue | Wife 1/4; Mother 1/3; Uncle 5/12; total exactly 1 | Passing |
| No residue left: the uncle receives nothing | Husband + two full sisters trigger 'awl; uncle listed as blocked | Passing |
| Sisters do not block uncles | Full sister 1/2; uncle 1/2; total exactly 1 | Passing |
| All four schools agree on uncle outcomes | Hanafi, Shafi'i, Maliki and Hanbali each give the uncle 5/12 | Passing |
Country adjustments (Section B)
Local-law adjustments that never change the Islamic calculation itself: prior deductions and the obligatory bequest (al-wasiyya al-wajiba) for grandchildren in countries such as Jordan and Egypt.
11 tests · src/lib/inheritance.jurisdiction.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| No options gives the same result as before | A zero prior deduction leaves net and every heir amount unchanged | Passing |
| Deducts the prior amount before distributing and before the voluntary bequest | 30,000 prior deduction on 90,000: net 60,000; a 20,000 bequest is fully capped away | Passing |
| Prior deduction cannot exceed one third | 80,000 requested on 90,000: 30,000 applied; net 60,000 | Passing |
| Returns null when no jurisdiction is selected | No country chosen: no adjustment | Passing |
| Returns null for a country without an obligatory bequest | United States: no adjustment | Passing |
| Returns null when no qualifying grandchildren are entered | No grandchildren: no adjustment | Passing |
| Caps the bequest at one third when the parent's hypothetical share is larger | Jordan, 90,000: bequest 30,000 (one third); wife's amount falls from 22,500 to 15,000 | Passing |
| Caps the bequest at the parent's hypothetical share when that is smaller | Bequest = 5/21 of 90,000 ≈ 21,429; mother keeps 1/6 of the reduced estate; sons' residue shrinks | Passing |
| Splits the bequest 2:1 between grandsons and granddaughters | Grandsons receive 2/3 and granddaughters 1/3 of the bequest; the parts sum to the whole | Passing |
| Lists every heir whose share changed as a deviation | Wife and Father listed; every adjusted amount is lower than the pure amount | Passing |
| getJurisdiction resolves entries by code | MY scope “allChildren”; EG scope “sonsDescendants”; unknown code “XX” returns null | Passing |
Two grandmothers & the provisional flag
Maternal and paternal grandmothers: who blocks whom, how they share the sixth, and the amber provisional flag for the Hanbali position on a paternal grandmother with a living father.
12 tests · src/lib/inheritance.grandmothers.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Flags the uncalculated Hanbali father/paternal-grandmother case but not Hanafi | Hanbali: unaccounted flag + “not calculated” note; Hanafi: no flag, paternal grandmother blocked by the father; school comparison shows the divergence | Passing |
| Includes the provisional warning in the Hanbali share text, immediately before the link | Shared summary contains “PROVISIONAL:” directly before the link, with and without an attached PDF | Passing |
| Does not include a provisional warning in Hanafi for the same family | Shared summary contains no “PROVISIONAL” line | Passing |
| Does not include a provisional warning for wife, son and two grandmothers | Shared summary contains no “PROVISIONAL” line | Passing |
| Does not flag grandmothers blocked by a living mother | No unaccounted entries; paternal grandmother blocked by the mother | Passing |
| A single maternal or paternal grandmother alone receives the whole estate by radd in Hanafi | One heir with share 1; basis “1/6 (fixed share by Sunnah; mother absent)” or “…mother and father absent” | Passing |
| Two grandmothers alone split the whole estate equally by radd in Hanafi | Maternal 1/2; paternal 1/2 | Passing |
| Wife and son with two grandmothers: 1/8, 1/12 each, 17/24 | Wife 1/8; each grandmother 1/12; son 17/24 | Passing |
| Both alive share 1/6 equally | Each grandmother 1/12 | Passing |
| Paternal grandmother alone takes 1/6 | Paternal grandmother 1/6 | Passing |
| Mother blocks both grandmothers | Neither grandmother inherits; two entries blocked by “Mother” | Passing |
| Father blocks paternal grandmother; maternal takes full 1/6 | Paternal grandmother blocked by “Father”; maternal grandmother 1/6 | Passing |
Unmodelled relatives
Relatives the calculator deliberately does not model (nephews, cousins, grandchildren through daughters, distant kindred): they must never change the numbers, only add clear guidance.
5 tests · src/lib/inheritance.unaccounted.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Empty selection produces no warning | No unaccounted entries | Passing |
| Results are identical with and without otherRelatives set | Same shares, same rule, same net whether or not unmodelled relatives are selected | Passing |
| Unaccounted lists the selected relatives with explanations | Each selected relative appears with its label and a non-empty explanation | Passing |
| Unknown keys are ignored | An unrecognised selection produces no unaccounted entries | Passing |
| Unaccounted is present even when no heirs can be computed | Rule “none” with the unmodelled relative still listed | Passing |
Numeral display
The display-only Arabic numeral preference: Eastern digits may be shown in the Arabic interface, but stored and calculated values always stay numeric, and English always uses Western digits.
3 tests · src/lib/numerals.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Uses Eastern digits in Arabic when selected | “$1,234.50 • 1/6 (12.50%)” renders with Eastern Arabic digits | Passing |
| Keeps Western digits in Arabic when selected and always in English | “1/6” stays Western in Arabic-western and in English regardless of preference | Passing |
| Accepts either script for editable amounts without changing the stored number | “١٢٣٤٫٥”, “1,234.5” and “۱۲۳۴٫۵” all parse to 1234.5 | Passing |
Wizard flow & share links
Which questions the location step turns on, the step counter, and private share links. None of these change any Islamic-law share.
7 tests · src/lib/wizard-flow.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Western country hides the wives count behind “More than one wife?” | US/GB → count assumed, default one wife | Passing |
| Country where the count is asked shows it | SA/PK → wives count asked directly | Passing |
| No location asks every question | No country → wives count asked | Passing |
| Location label follows the mode | Administer: “Where did the deceased live?”; Plan: “Where do you live?” | Passing |
| Location is its own early step; counter stays accurate | Step 2 is Location; “Step X of N” never exceeds N | Passing |
| New share links keep the case in #c= | Link contains #c= and no ?c= | Passing |
| Old ?c= links still load and convert to #c= | /?lang=ar&c=… reopens the case and becomes /?lang=ar#c=… | Passing |
Results guidance (debts, mahr, beneficiary forms)
The guidance notes on the results screen: the unpaid-mahr debt hint, the debts-exceed-estate message, and the beneficiary-forms card. None of these change any Islamic-law share.
5 tests · src/lib/results-notes.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Calculations are unchanged for an existing case | Wife 1/8 (30,000), son 7/8 (210,000) on a 240,000 estate | Passing |
| Mahr line shows for a male deceased with a wife and debts above zero | Note shown | Passing |
| Mahr line hidden for a female deceased, no spouse, or no debts | Note hidden in all three cases | Passing |
| Debts above the gross estate: message shown, net 0, no amounts | Message shown; net 0; every heir amount 0; hidden when debts are below the estate | Passing |
| Beneficiary card appears in Plan mode only and hides once dismissed | Shown in Plan, hidden in Administer, hidden after dismissing | Passing |
Asset division tool (Administer mode)
The optional 'Divide the actual assets' tool. It uses the amounts from the results and never recomputes shares; items stay in the browser only.
20 tests · src/lib/asset-division.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| House to son, car and cash held in proportion (gross 800) | Son receives 775 (+75), wife 25 (−75); son pays wife 75.00 | Passing |
| Debts 200: house to son, cash 400 sold or set aside | Son −100, wife −100, estate cash +200; estate cash pays son 100 and wife 100 | Passing |
| Items totaling 900 against an estate of 1000 with no deductions | Unreconciled amount of 100 against the net estate | Passing |
| Button hidden in Plan mode, with a treasury row, and with the provisional flag | Hidden; 'not available' line for treasury and provisional cases | Passing |
| Nothing from the tool appears in share link or share text | No item names or division wording in either | Passing |
| Three heirs with a value not divisible by three | Payments total exactly, to the cent | Passing |
| Zero estate cash is omitted from the displayed parties | Cash stays in settlement arithmetic but is hidden from the display | Passing |
| Estate cash with debts, costs, bequest, or assigned items | Cash party is displayed when entitled or receiving an amount above zero | Passing |
| Estate pays heirs and retains debt funds | The estate pays Wife $100.00 and Son $100.00; $200.00 remains for debts, funeral costs and any bequest; debts note shown | Passing |
| No-debts case hides leftover and debt guidance | No estate-cash leftover line or debt note | Passing |
| Reconciles against the net estate (estate 1000, debts 200, items 800 in proportion) | Left to divide 800, difference 0; 200 of debts flagged as not yet covered | Passing |
| PDF viewer wording | 'View PDF' and 'Back to the division tool' present; every division string bilingual | Passing |
| Debts line covered, under and over | Exactly 200 assigned: no message, no payments; 300 assigned: 100 more than needed | Passing |
| 'Already paid' box ticked, only remaining 800 listed | Difference 0, no coverage message, debts line hidden | Passing |
| Custom split by percent and amount, and an invalid total | 50/50 settles; 70/30 amounts: one heir pays the other 20; 80% split flagged and the unassigned 20% held in proportion; negative or over-value entries flagged | Passing |
| Prefill from itemized assets ($700,000, debts and funeral $50,000, spouse, son, daughter) | One row per asset at the Islamic counted value, legal-title tag kept; $50,000 of cash to debts gives difference 0 and heirs exactly their shares; list changes keep assignments | Passing |
| No itemized assets | Starts with one blank item added by hand | Passing |
| Currency | Amounts show in the selected currency (€, £) | Passing |
| Saved cases carry the distribution list | List, assignments and 'already paid' box restored; older files open without a list | Passing |
| Confirmed saved case replaces an open distribution | Visible items, assignments and already-paid box refresh from the loaded case; older saves clear the former list | Passing |
After-a-death checklist
The practical checklist page. General guidance only; ticked steps stay in the browser and are never saved or shared.
7 tests · src/lib/after-death.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Every heading and step has English and Arabic text | 7 groups, 20 steps, all bilingual | Passing |
| Scholar icon marks religious-ruling steps | Funeral, bequest, and religious-obligation steps only | Passing |
| 'What to do next' link on results | Shown in Administer mode, hidden in Plan mode | Passing |
| Local notes follow the chosen country | Country's existing notes shown; prompt shown when none is set | Passing |
| Back link with a calculation held | Reads 'Back to calculated shares' and reopens the results, keeping the language | Passing |
| Back link with no calculation held | Reads 'Raashid calculator' and opens the calculator start | Passing |
| Start over clears the remembered case | Checklist resets to the no-calculation state after Start over | Passing |
Attorney worksheet (Plan mode)
The optional worksheet for your attorney. Answers stay in browser memory for the session and never reach the URL, share links, share text or the case PDF.
8 tests · src/lib/worksheet.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Results callouts by mode | Worksheet callout in Plan mode only; 'What to do next' in Administer mode only | Passing |
| Back link and buttons follow the calculation in memory | Plan: 'Back to your results'; none: 'Raashid calculator'; Administer: note pointing to After a death | Passing |
| Answers survive navigation, cleared on reload | Saved answers return after visiting results; a fresh load starts empty | Passing |
| One-third bequest warning | Warning above one third of the net estate (or 33.33% without a calculation); heir note text present | Passing |
| Skip and the children question | Skip moves on from every screen; 'No' skips the guardian screen | Passing |
| Worksheet answers stay private | Nothing entered appears in the share link | Passing |
| Printout text and funeral helper | Closing text, no-schedule note and funeral helper present; every string bilingual | Passing |
| Percent bequests and the PDF viewer wording | Percentage explained as a share of the net estate; 'View PDF' and 'Back to your worksheet' present in both languages | Passing |
Leaving more to one heir
The educational page on gifts, debts and bequests to one heir. It collects no data and changes no calculation.
7 tests · src/lib/one-heir.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Seven items, statuses, legend and open questions | 7 bilingual items (3 valid, 3 not permitted, 1 open); 6 open questions | Passing |
| Worked example figures | Wife $37,500 + $200,000 = $237,500, son $262,500; husband $50,000, son $150,000, husband left $350,000 | Passing |
| Only listed sources | Exactly S1–S13 from the approved sites; every cited source exists | Passing |
| Back link | '← Back' after a same-site page; '← Raashid home' otherwise | Passing |
| Debts tip link | 'See Leaving more to one heir.' in English and Arabic | Passing |
| Spouse-or-heir card is a bulleted list | Title '…spouse or another heir'; 5 bilingual bullets; old paragraph wording gone | Passing |
| Sources show titles, never raw addresses | Each of S1–S13 shows a title or reference numbers plus a site label (Quran.com, Sunnah.com, Islam Q&A…); no 'http' in the visible text | Passing |
Family tree view
The optional Family tree screen writes the same answers as the question steps. These tests rebuild many family set-ups through the tree, check its own copies of step rules, keep names out of share links, and confirm the results-page what-if view never touches the real answers.
16 tests · src/lib/family-tree-parity.test.ts
| Test case | Expected result | Actual result |
|---|---|---|
| Tree path gives identical answers and results to the question path | 27 family set-ups rebuilt with tree actions match exactly | Passing |
| Wives one to four; one assumed in a monogamous country | 9 → 4; US assumes one wife until asked | Passing |
| Female deceased shows a husband | Husband 1/2; wives names refused | Passing |
| Mother suppresses grandmothers | Maternal grandmother shown as blocked | Passing |
| Maternal siblings are one combined count | Three maternal siblings share 1/3 | Passing |
| Shares that differ by school are flagged | Grandfather with brothers flagged; wife alone not | Passing |
| Names are trimmed and capped | Fewer sons drops extra names; 30 characters max | Passing |
| Share links never carry names | #z=, #c= and the after-death snapshot contain no names | Passing |
| Names kept in saved files and drafts | Saved file and session draft keep the names | Passing |
| Name labels and PDF print modes | "Zayd (Son 1)"; Arabic uses Amiri; unsupported scripts fall back | Passing |
| Old files, links and drafts still open | No names or view choice needed | Passing |
| Step order on each path | Tree path has 5 steps; switching maps to the matching step | Passing |
| What-if edits never reach the real answers | Real answers, link and draft unchanged; reopening starts fresh | Passing |
| Tree amounts match the results table | Equal to the cent for every set-up | Passing |
| Tree PDF what-if label | Shown only when the tree differs | Passing |
| Every family field is covered by the tree | Fails if a family field is added without tree support | Passing |
These tests verify the arithmetic and rules of the calculator. They are not a substitute for scholarly review of a specific estate; rare cases flagged during use should always be taken to a qualified Islamic scholar. If you believe a result is wrong, please tell us through the feedback form so we can investigate.