@@ -19,7 +19,7 @@ describe('HyperMath', () => {
19
19
20
20
it ( 'should throw an error if the input is invalid' , ( ) => {
21
21
expect ( ( ) => {
22
- HyperMath . multiply ( 'abc' , 3 ) ;
22
+ HyperMath . multiply ( 'abc' , null ) ;
23
23
} ) . toThrow ( 'Invalid input' ) ;
24
24
} ) ;
25
25
} ) ;
@@ -69,4 +69,27 @@ describe('HyperMath', () => {
69
69
} ) . toThrow ( 'Invalid input' ) ;
70
70
} ) ;
71
71
} ) ;
72
+
73
+ describe ( 'subtract' , ( ) => {
74
+ it ( 'should subtract two numbers correctly' , ( ) => {
75
+ const result = HyperMath . subtract ( 7 , 5 ) ;
76
+ expect ( result ) . toBe ( 2 ) ;
77
+ } ) ;
78
+
79
+ it ( 'should subtract two values with decimals correctly' , ( ) => {
80
+ const result = HyperMath . subtract ( 8.5 , '3.3' ) ;
81
+ expect ( result ) . toBe ( 5.2 ) ;
82
+ } ) ;
83
+
84
+ it ( 'should subtract two strings that represent numbers correctly' , ( ) => {
85
+ const result = HyperMath . subtract ( '9' , '5' ) ;
86
+ expect ( result ) . toBe ( 4 ) ;
87
+ } ) ;
88
+
89
+ it ( 'should throw an error if the input is invalid' , ( ) => {
90
+ expect ( ( ) => {
91
+ HyperMath . subtract ( undefined , 3 ) ;
92
+ } ) . toThrow ( 'Invalid input' ) ;
93
+ } ) ;
94
+ } ) ;
72
95
} ) ;
0 commit comments