File tree 2 files changed +13
-3
lines changed
2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change
1
+ import { CalculatorService } from './calculator.service' ;
2
+ import { LoggerService } from './logger.service' ;
1
3
2
4
3
5
describe ( 'CalculatorService' , ( ) => {
4
6
5
7
6
8
it ( 'should add two numbers' , ( ) => {
7
9
8
- pending ( ) ;
10
+ const calculator = new CalculatorService ( new LoggerService ( ) ) ;
11
+
12
+ const result = calculator . add ( 2 , 2 ) ;
13
+
14
+ expect ( result ) . toBe ( 4 ) ;
9
15
10
16
} ) ;
11
17
12
18
13
19
it ( 'should subtract two numbers' , ( ) => {
14
20
15
- fail ( ) ;
21
+ const calculator = new CalculatorService ( new LoggerService ( ) ) ;
22
+
23
+ const result = calculator . subtract ( 2 , 2 ) ;
24
+
25
+ expect ( result ) . toBe ( 0 , "unexpected subtraction result" ) ;
16
26
17
27
} ) ;
18
28
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export class CalculatorService {
19
19
20
20
subtract ( n1 : number , n2 :number ) {
21
21
this . logger . log ( "Subtraction operation called" ) ;
22
- return n1 - n2 ;
22
+ return n1 * n2 ;
23
23
}
24
24
25
25
You can’t perform that action at this time.
0 commit comments