-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalbumsCost.test.js
186 lines (155 loc) · 6.14 KB
/
albumsCost.test.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
const { calcularPrecio } = require('./albumsCost.js');
/**
* 1. Implementar TEST
* 2. Agregar el código necesario para que pase el test
* 3. Pasar el test
*/
describe('Suitcase: Calculate price when the number of pages is not even-par', ()=> {
it('Should return undefined when the number of pages is ood and binding is rustic', () => {
const numPags = 23;
const tipoEncuad = "R";
const cantidad = 1
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBeUndefined();
})
it('Should return undefined when the number of pages is ood and binding is case', () => {
const numPags = 37;
const tipoEncuad = "C";
const cantidad = 1
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBeUndefined();
})
})
describe('Suitcase: Calculate price for rustic binding', ()=> {
test('Should return 20.00 € when number of pages is 20', () => {
const numPags = 20;
const tipoEncuad = "R";
const cantidad = 1;
const totalPrice = 20.00;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return 20.07 € when number of pages is 22', () => {
const numPags = 22;
const tipoEncuad = "R";
const cantidad = 1;
const totalPrice = 20.7;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return 21.4 € when number of pages is 24', () => {
const numPags = 24;
const tipoEncuad = "R";
const cantidad = 1;
const totalPrice = 21.4;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return 44.2 € when order 2 units and number of pages is 26', () => {
const numPags = 26;
const tipoEncuad = "R";
const cantidad = 2;
const totalPrice = 44.2;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return undefined when number of pages is 120', () => {
const numPags = 120;
const tipoEncuad = "R";
const cantidad = 1;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBeUndefined();
})
test('A 10% discount is applied for an order of 5 units.', () => {
const numPags = 20;
const tipoEncuad = "R";
const cantidad = 5;
const totalPrice = 90;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('A 25% discount is applied for an order of 10 units.', () => {
const numPags = 20;
const tipoEncuad = "R";
const cantidad = 10;
const totalPrice = 150;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('A 25% discount is applied for an order of 250 units.', () => {
const numPags = 20;
const tipoEncuad = "R";
const cantidad = 250;
const totalPrice = 3750;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return undefined for 260 units orders', () => {
const numPags = 20;
const tipoEncuad = "R";
const cantidad = 260;
const totalPrice = undefined;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
})
describe('Suitcase: Calculate price for case binding', ()=> {
test('Should return 30 € when number of pages is 20', () => {
const numPags = 20;
const tipoEncuad = "C";
const cantidad = 1;
const totalPrice = 30;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return 31 € when number of pages is 22', () => {
const numPags = 22;
const tipoEncuad = "C";
const cantidad = 1;
const totalPrice = 31;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return 32 € when number of pages is 24', () => {
const numPags = 24;
const tipoEncuad = "C";
const cantidad = 1;
const totalPrice = 32;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return 66 € when number of pages is 26', () => {
const numPags = 26;
const tipoEncuad = "C";
const cantidad = 2;
const totalPrice = 66;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return undefined when number of pages is less of 20', () => {
const numPags = 18;
const tipoEncuad = "C";
const cantidad = 1;
const totalPrice = undefined;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return undefined when number of pages is 130', () => {
const numPags = 130;
const tipoEncuad = "C";
const cantidad = 1;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBeUndefined();
})
test('A 10% discount is applied for an order of 5 units.', () => {
const numPags = 20;
const tipoEncuad = "C";
const cantidad = 5;
const totalPrice = 135;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('A 25% discount is applied for an order of 10 units.', () => {
const numPags = 20;
const tipoEncuad = "C";
const cantidad = 10;
const totalPrice = 225;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('A 25% discount is applied for an order of 250 units.', () => {
const numPags = 20;
const tipoEncuad = "C";
const cantidad = 250;
const totalPrice = 5625;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
test('Should return undefined for 260 units orders', () => {
const numPags = 20;
const tipoEncuad = "C";
const cantidad = 260;
const totalPrice = undefined;
expect(calcularPrecio(numPags, tipoEncuad, cantidad)).toBe(totalPrice);
})
})