-
Notifications
You must be signed in to change notification settings - Fork 0
/
a.spec.ts
48 lines (46 loc) · 1.08 KB
/
a.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { Province, sampleProvinceData } from '.';
describe('province', () => {
let asia: Province;
beforeEach(() => {
asia = new Province(sampleProvinceData());
});
it('shorfall', () => {
expect(asia.shortfall).toBe(5);
});
it('profit', () => {
expect(asia.profit).toBe(230);
});
it('change production', () => {
asia.producers[0].production = 20;
expect(asia.shortfall).toBe(-6);
expect(asia.profit).toBe(292);
});
it('zero demand', () => {
asia.demand = 0;
expect(asia.shortfall).toBe(-25);
expect(asia.profit).toBe(0);
});
it('negative demand', () => {
asia.demand = -1;
expect(asia.shortfall).toBe(-26);
expect(asia.profit).toBe(-10);
});
});
describe('no producers', () => {
let noProducers: Province;
beforeEach(() => {
const data = {
name: 'No producers',
producers: [],
demand: 30,
price: 20,
};
noProducers = new Province(data);
});
it('shortfall', () => {
expect(noProducers.shortfall).toBe(30);
});
it('profit', () => {
expect(noProducers.profit).toBe(0);
});
});