Add license information.
[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 p = Person.self('A');
30 const tr = new TaxReturn();
31 tr.addForm(new Form1040({ filingStatus }));
32 tr.addForm(new W2({
33 employer: 'Acme',
34 employee: p,
35 wages: 300000,
36 fedIncomeTax: 0,
37 medicareWages: 300000,
38 medicareTax: 5000,
39 }));
40
41 const form = new Form8959();
42 tr.addForm(new Form8959());
43 tr.addForm(new Schedule2());
44
45 expect(form.getValue(tr, '4')).toBe(300000);
46 expect(form.getValue(tr, '5')).toBe(Form8959.filingStatusLimit(filingStatus));
47 expect(form.getValue(tr, '6')).toBe(filingStatusToResults[filingStatus]['6']);
48 expect(form.getValue(tr, '18')).toBeCloseTo(form.getValue(tr, '6') * 0.009);
49
50 expect(form.getValue(tr, '19')).toBe(5000);
51 expect(form.getValue(tr, '20')).toBe(form.getValue(tr, '1'));
52 expect(form.getValue(tr, '21')).toBeCloseTo(300000 * 0.0145);
53 expect(form.getValue(tr, '22')).toBeCloseTo(650);
54
55 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
56 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(650);
57 });
58 }
59 });
60
61 describe('no additional medicare tax', () => {
62 for (const filingStatus of Object.values(FilingStatus)) {
63 test(`filing status ${filingStatus}`, () => {
64 const p = Person.self('A');
65 const tr = new TaxReturn();
66 tr.addForm(new Form1040({ filingStatus }));
67 tr.addForm(new W2({
68 employer: 'Acme',
69 employee: p,
70 wages: 110000,
71 fedIncomeTax: 0,
72 medicareWages: 110000,
73 medicareTax: 5000,
74 }));
75
76 const form = new Form8959();
77 tr.addForm(new Form8959());
78 tr.addForm(new Schedule2());
79
80 expect(form.getValue(tr, '4')).toBe(110000);
81 expect(form.getValue(tr, '5')).toBe(Form8959.filingStatusLimit(filingStatus));
82 expect(form.getValue(tr, '6')).toBe(0);
83 expect(form.getValue(tr, '18')).toBe(0);
84
85 expect(form.getValue(tr, '19')).toBe(5000);
86 expect(form.getValue(tr, '20')).toBe(form.getValue(tr, '1'));
87 expect(form.getValue(tr, '21')).toBeCloseTo(110000 * 0.0145);
88 expect(form.getValue(tr, '22')).toBeCloseTo(3405);
89
90 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
91 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(3405);
92 });
93 }
94 });