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
6 import { Person } from '../core';
9 import Form8959 from './Form8959';
10 import Form1040, { FilingStatus } from './Form1040';
11 import Schedule2 from './Schedule2';
12 import TaxReturn from './TaxReturn';
14 describe('additional medicare tax', () => {
15 const filingStatusToResults = {
16 [FilingStatus.Single]: {
19 [FilingStatus.MarriedFilingJoint]: {
22 [FilingStatus.MarriedFilingSeparate]: {
27 for (const filingStatus of Object.values(FilingStatus)) {
28 test(`filing status ${filingStatus}`, () => {
29 const tr = new TaxReturn();
30 const p = Person.self('A');
32 tr.addForm(new Form1040({ filingStatus }));
38 medicareWages: 300000,
42 const form = new Form8959();
43 tr.addForm(new Form8959());
44 tr.addForm(new Schedule2());
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);
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);
56 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
57 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(650);
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');
68 tr.addForm(new Form1040({ filingStatus }));
74 medicareWages: 110000,
78 const form = new Form8959();
79 tr.addForm(new Form8959());
80 tr.addForm(new Schedule2());
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);
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);
92 expect(tr.getForm(Schedule2).getValue(tr, '8')).toBe(form.getValue(tr, '18'));
93 expect(tr.getForm(Form1040).getValue(tr, '17')).toBe(3405);