@@ -15,35 +15,38 @@ describe("Compute Capacity module", () => {
15
15
const cpu = 0 ;
16
16
const mem = 255 * 1024 ** 2 ;
17
17
18
- computeCapacity . cpu = cpu ;
19
- computeCapacity . memory = mem ;
20
-
18
+ const setCPU = ( ) => ( computeCapacity . cpu = cpu ) ;
19
+ const setMem = ( ) => ( computeCapacity . memory = mem ) ;
21
20
const result = ( ) => computeCapacity . challenge ( ) ;
22
21
22
+ expect ( setCPU ) . toThrow ( ) ;
23
+ expect ( setMem ) . toThrow ( ) ;
23
24
expect ( result ) . toThrow ( ) ;
24
25
} ) ;
25
26
26
27
test ( "Max values for cpu & memory." , ( ) => {
27
28
const cpu = 33 ;
28
29
const mem = 255 * 1024 ** 4 ;
29
30
30
- computeCapacity . cpu = cpu ;
31
- computeCapacity . memory = mem ;
32
-
31
+ const setCPU = ( ) => ( computeCapacity . cpu = cpu ) ;
32
+ const setMem = ( ) => ( computeCapacity . memory = mem ) ;
33
33
const result = ( ) => computeCapacity . challenge ( ) ;
34
34
35
+ expect ( setCPU ) . toThrow ( ) ;
36
+ expect ( setMem ) . toThrow ( ) ;
35
37
expect ( result ) . toThrow ( ) ;
36
38
} ) ;
37
39
38
40
test ( "cpu & memory doesn't accept decimal values." , ( ) => {
39
41
const cpu = 1.5 ;
40
42
const mem = 1.2 ;
41
43
42
- computeCapacity . cpu = cpu ;
43
- computeCapacity . memory = mem ;
44
-
44
+ const setCPU = ( ) => ( computeCapacity . cpu = cpu ) ;
45
+ const setMem = ( ) => ( computeCapacity . memory = mem ) ;
45
46
const result = ( ) => computeCapacity . challenge ( ) ;
46
47
48
+ expect ( setCPU ) . toThrow ( ) ;
49
+ expect ( setMem ) . toThrow ( ) ;
47
50
expect ( result ) . toThrow ( ) ;
48
51
} ) ;
49
52
@@ -57,11 +60,12 @@ describe("Compute Capacity module", () => {
57
60
const negative_cpu = - 1 ;
58
61
const negative_mem = - 1 ;
59
62
60
- computeCapacity . cpu = negative_cpu ;
61
- computeCapacity . memory = negative_mem ;
62
-
63
+ const setCPU = ( ) => ( computeCapacity . cpu = negative_cpu ) ;
64
+ const setMem = ( ) => ( computeCapacity . memory = negative_mem ) ;
63
65
const result = ( ) => computeCapacity . challenge ( ) ;
64
66
67
+ expect ( setCPU ) . toThrow ( ) ;
68
+ expect ( setMem ) . toThrow ( ) ;
65
69
expect ( result ) . toThrow ( ) ;
66
70
} ) ;
67
71
} ) ;
0 commit comments