Add a test for Form8959.
[ustaxlib.git] / src / fed2019 / Form8959.test.ts
1 import Person from '../Person';
2 import TaxReturn from '../TaxReturn';
3
4 import FormW2 from './FormW2';
5 import Form8959 from './Form8959';
6 import Form1040, { Schedule2, FilingStatus } from './Form1040';
7
8 describe('additional medicare tax', () => {
9 const filingStatusToResults = {
10 [FilingStatus.Single]: {
11 '6': 100000,
12 },
13 [FilingStatus.MarriedFilingJoint]: {
14 '6': 50000,
15 },
16 [FilingStatus.MarriedFilingSeparate]: {
17 '6': 175000,
18 }
19 };
20
21 for (const filingStatus of Object.values(FilingStatus)) {
22 test(`filing status ${filingStatus}`, () => {
23 const p = Person.self('A');
24 const tr = new TaxReturn(2019);
25 tr.addForm(new Form1040({ filingStatus }));
26 tr.addForm(new FormW2({
27 employer: 'Acme',
28 employee: p,
29 wages: 300000,
30 fedIncomeTax: 0,
31 medicareWages: 300000,
32 medicareTax: 5000,
33 }));
34
35 const form = new Form8959();
36 tr.addForm(new Form8959());
37 tr.addForm(new Schedule2());
38
39 expect(form.getValue(tr, '4')).toBe(300000);
40 expect(form.getValue(tr, '5')).toBe(Form8959.filingStatusLimit(filingStatus));
41 expect(form.getValue(tr, '6')).toBe(filingStatusToResults[filingStatus]['6']);
42 expect(form.getValue(tr, '18')).toBeCloseTo(form.getValue(tr, '6') * 0.009);
43
44 expect(form.getValue(tr, '19')).toBe(5000);
45 expect(form.getValue(tr, '20')).toBe(form.getValue(tr, '1'));
46 expect(form.getValue(tr, '21')).toBeCloseTo(300000 * 0.0145);
47 expect(form.getValue(tr, '22')).toBeCloseTo(650);
48
49 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
50 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(650);
51 });
52 }
53 });
54
55 describe('no additional medicare tax', () => {
56 for (const filingStatus of Object.values(FilingStatus)) {
57 test(`filing status ${filingStatus}`, () => {
58 const p = Person.self('A');
59 const tr = new TaxReturn(2019);
60 tr.addForm(new Form1040({ filingStatus }));
61 tr.addForm(new FormW2({
62 employer: 'Acme',
63 employee: p,
64 wages: 110000,
65 fedIncomeTax: 0,
66 medicareWages: 110000,
67 medicareTax: 5000,
68 }));
69
70 const form = new Form8959();
71 tr.addForm(new Form8959());
72 tr.addForm(new Schedule2());
73
74 expect(form.getValue(tr, '4')).toBe(110000);
75 expect(form.getValue(tr, '5')).toBe(Form8959.filingStatusLimit(filingStatus));
76 expect(form.getValue(tr, '6')).toBe(0);
77 expect(form.getValue(tr, '18')).toBe(0);
78
79 expect(form.getValue(tr, '19')).toBe(5000);
80 expect(form.getValue(tr, '20')).toBe(form.getValue(tr, '1'));
81 expect(form.getValue(tr, '21')).toBeCloseTo(110000 * 0.0145);
82 expect(form.getValue(tr, '22')).toBeCloseTo(3405);
83
84 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
85 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(3405);
86 });
87 }
88 });