Begin defining a TaxReturn and Person model.
[ustaxlib.git] / src / TaxReturn.test.ts
1 import TaxReturn from './TaxReturn';
2 import { Person } from './Person';
3
4 test('constructor', () => {
5 const tr = new TaxReturn(2019);
6 expect(tr.year).toBe(2019);
7 });
8
9 test('does not support Dependents', () => {
10 const tr = new TaxReturn(2019);
11 const p = Person.dependent('Baby');
12 expect(() => tr.addPerson(p)).toThrow('Dependents are not supported');
13 });
14
15 test('add more than one Self', () => {
16 const tr = new TaxReturn(2019);
17 const p1 = Person.self('A');
18 tr.addPerson(p1);
19 const p2 = Person.self('B');
20 expect(() => tr.addPerson(p2)).toThrow('Cannot have more than one Self or Spouse');
21 });
22
23 test('add more than one Spouse', () => {
24 const tr = new TaxReturn(2019);
25 const p1 = Person.spouse('A');
26 tr.addPerson(p1);
27 const p2 = Person.spouse('B');
28 expect(() => tr.addPerson(p2)).toThrow('Cannot have more than one Self or Spouse');
29 });
30
31 test('add Self and Spouse', () => {
32 const tr = new TaxReturn(2019);
33 const self = Person.self('Billy Bob');
34 const spouse = Person.spouse('Jilly Bob');
35 tr.addPerson(self);
36 tr.addPerson(spouse);
37
38 expect(tr.getPerson('Billy')).toBe(self);
39 expect(tr.getPerson('Jilly')).toBe(spouse);
40
41 expect(() => tr.getPerson('Bob')).toThrow('too imprecise');
42 });
43
44 test('get non-existent person', () => {
45 const tr = new TaxReturn(2019);
46 const self = Person.self('Billy Bob');
47 tr.addPerson(self);
48
49 expect(tr.getPerson('Billy Bob')).toBe(self);
50 expect(() => tr.getPerson('Jilly')).toThrow('not found');
51 });