Skip to content

Commit e4d17ae

Browse files
committed
mouredev#13 - JavaScript
1 parent 6cf1732 commit e4d17ae

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Pruebas Unitarias
2+
3+
// Una funcion Sumar en un archivo math.js
4+
5+
function sumar(a, b) {
6+
return a + b;
7+
}
8+
9+
module.exports = sumar;
10+
11+
12+
// La prueba unitaria de dicha funcion se hara en un archivo separado llamado math.test.js
13+
14+
const sumar = require('./math');
15+
16+
test('sumar 1 + 2 debe ser igual a 3', () => {
17+
expect(sumar(1, 2)).toBe(3);
18+
});
19+
20+
test('sumar -1 + 1 debe ser igual a 0', () => {
21+
expect(sumar(-1, 1)).toBe(0);
22+
});
23+
24+
// Para ejecutar la prueba en Jest se utiliza el comando npx jest

0 commit comments

Comments
 (0)