Skip to content

Commit 5f9e25f

Browse files
author
Your Name
committed
Angular Testing Course
1 parent 8b9166a commit 5f9e25f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/app/courses/services/calculator.service.spec.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
1+
import {CalculatorService} from './calculator.service';
2+
import {LoggerService} from './logger.service';
13

24

35
describe('CalculatorService', () => {
46

57

68
it('should add two numbers', () => {
79

8-
pending();
10+
const calculator = new CalculatorService(new LoggerService());
11+
12+
const result = calculator.add(2, 2);
13+
14+
expect(result).toBe(4);
915

1016
});
1117

1218

1319
it('should subtract two numbers', () => {
1420

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");
1626

1727
});
1828

src/app/courses/services/calculator.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class CalculatorService {
1919

2020
subtract(n1: number, n2:number) {
2121
this.logger.log("Subtraction operation called");
22-
return n1 - n2;
22+
return n1 * n2;
2323
}
2424

2525

0 commit comments

Comments
 (0)