forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// npm install --save-dev jest | ||
// We name the file with the ending .test.js | ||
|
||
function addition(a, b) { | ||
return a + b; | ||
} | ||
|
||
test('addition 1 + 2 should be 3', () => { | ||
expect(addition(1, 2)).toBe(3); | ||
}); | ||
|
||
test('addition 3 + 7 should be 10', () => { | ||
expect(addition(3, 7)).toBe(10); | ||
}); | ||
|
||
// To run the program: npx jest .\Sac-Corts.test.js | ||
|
||
// Extra Exercise | ||
|
||
const data = { | ||
name: "Isaac", | ||
age: "22", | ||
birthdate: "2001-10-21", | ||
programmingLanguages: ["JavaScript", "Python"] | ||
} | ||
|
||
test('It should have all the necessary keys', () => { | ||
expect(data).toHaveProperty('name'); | ||
expect(data).toHaveProperty('age'); | ||
expect(data).toHaveProperty('birthdate'); | ||
expect(data).toHaveProperty('programmingLanguages'); | ||
}); | ||
|
||
test('It should have the correct data', () => { | ||
expect(data.name).toBe("Isaac"); | ||
expect(data.age).toBe("22"); | ||
expect(data.birthdate).toBe("2001-10-21"); | ||
expect(data.programmingLanguages).toEqual(["JavaScript", "Python"]); | ||
}); |