Extract constant values from fed2019 Forms as named definitions.
[ustaxlib.git] / src / fed2019 / Form8959.test.ts
1 // Copyright 2020 Blue Static <https://www.bluestatic.org>
2 // This program is free software licensed under the GNU General Public License,
3 // version 3.0. The full text of the license can be found in LICENSE.txt.
4 // SPDX-License-Identifier: GPL-3.0-only
5
6 import { Person } from '../core';
7
8 import W2 from './W2';
9 import Form8959 from './Form8959';
10 import Form1040, { FilingStatus } from './Form1040';
11 import Schedule2 from './Schedule2';
12 import TaxReturn from './TaxReturn';
13
14 describe('additional medicare tax', () => {
15 const filingStatusToResults = {
16 [FilingStatus.Single]: {
17 '6': 100000,
18 },
19 [FilingStatus.MarriedFilingJoint]: {
20 '6': 50000,
21 },
22 [FilingStatus.MarriedFilingSeparate]: {
23 '6': 175000,
24 }
25 };
26
27 for (const filingStatus of Object.values(FilingStatus)) {
28 test(`filing status ${filingStatus}`, () => {
29 const tr = new TaxReturn();
30 const p = Person.self('A');
31 tr.addPerson(p);
32 tr.addForm(new Form1040({ filingStatus }));
33 tr.addForm(new W2({
34 employer: 'Acme',
35 employee: p,
36 wages: 300000,
37 fedIncomeTax: 0,
38 medicareWages: 300000,
39 medicareTax: 5000,
40 }));
41
42 const form = new Form8959();
43 tr.addForm(new Form8959());
44 tr.addForm(new Schedule2());
45
46 expect(form.getValue(tr, '4')).toBe(300000);
47 expect(form.getValue(tr, '5')).toBe(Form8959.filingStatusLimit(tr));
48 expect(form.getValue(tr, '6')).toBe(filingStatusToResults[filingStatus]['6']);
49 expect(form.getValue(tr, '18')).toBeCloseTo(form.getValue(tr, '6') * 0.009);
50
51 expect(form.getValue(tr, '19')).toBe(5000);
52 expect(form.getValue(tr, '20')).toBe(form.getValue(tr, '1'));
53 expect(form.getValue(tr, '21')).toBeCloseTo(300000 * 0.0145);
54 expect(form.getValue(tr, '22')).toBeCloseTo(650);
55
56 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
57 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(650);
58 });
59 }
60 });
61
62 describe('no additional medicare tax', () => {
63 for (const filingStatus of Object.values(FilingStatus)) {
64 test(`filing status ${filingStatus}`, () => {
65 const tr = new TaxReturn();
66 const p = Person.self('A');
67 tr.addPerson(p);
68 tr.addForm(new Form1040({ filingStatus }));
69 tr.addForm(new W2({
70 employer: 'Acme',
71 employee: p,
72 wages: 110000,
73 fedIncomeTax: 0,
74 medicareWages: 110000,
75 medicareTax: 5000,
76 }));
77
78 const form = new Form8959();
79 tr.addForm(new Form8959());
80 tr.addForm(new Schedule2());
81
82 expect(form.getValue(tr, '4')).toBe(110000);
83 expect(form.getValue(tr, '5')).toBe(Form8959.filingStatusLimit(tr));
84 expect(form.getValue(tr, '6')).toBe(0);
85 expect(form.getValue(tr, '18')).toBe(0);
86
87 expect(form.getValue(tr, '19')).toBe(5000);
88 expect(form.getValue(tr, '20')).toBe(form.getValue(tr, '1'));
89 expect(form.getValue(tr, '21')).toBeCloseTo(110000 * 0.0145);
90 expect(form.getValue(tr, '22')).toBeCloseTo(3405);
91
92 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
93 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(3405);
94 });
95 }
96 });