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