Skip to content

Commit cce7c24

Browse files
committed
jest and testing
1 parent b31a586 commit cce7c24

4 files changed

Lines changed: 4488 additions & 0 deletions

File tree

prep/example.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const yearOfBirth = 1990; // declaration
2+
let currentYear = 2023; // declaration
3+
4+
currentYear++; // statement
5+
`I am ${currentYear - yearOfBirth} years old`; // statement
6+
7+
console.log(`I am ${currentYear - yearOfBirth} years old`); // statement
8+
console.log("hello there")

prep/example1.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Explanation: This file contains a function `getLargest` that takes three numbers as input and returns the largest of the three. The function uses conditional statements to compare the numbers and determine which one is the largest. The test case at the bottom checks if the function correctly identifies the largest number in various scenarios, including when all numbers are the same.
2+
3+
function getLargest(a, b, c) {
4+
if (a >= b && a >= c) {
5+
return a;
6+
}
7+
if (b >= a && b >= c) {
8+
return b;
9+
}
10+
return c;
11+
}
12+
13+
test("returns the largest of three numbers", () => {
14+
expect(getLargest(1, 2, 3)).toEqual(3);
15+
expect(getLargest(10, 5, 7)).toEqual(10);
16+
expect(getLargest(4, 9, 6)).toEqual(9);
17+
expect(getLargest(5, 5, 5)).toEqual(5);
18+
});

0 commit comments

Comments
 (0)