-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathchallenge.test.js
More file actions
109 lines (90 loc) · 3.1 KB
/
challenge.test.js
File metadata and controls
109 lines (90 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { describe, it, expect } from "vitest";
const {
obtenerPI,
obtenerContador,
obtenerNombreCurso,
reasignarMensaje,
calcularTotal,
identificarTipos,
demostrarHoisting,
} = require("./challenge.js");
describe("Reto 01 - Var, Let y Const", () => {
describe("Reto 1: obtenerPI", () => {
it("debe retornar el valor 3.14159", () => {
expect(obtenerPI()).toBe(3.14159);
});
it("debe retornar un número", () => {
expect(typeof obtenerPI()).toBe("number");
});
});
describe("Reto 2: obtenerContador", () => {
it("debe retornar 5 después de reasignar", () => {
expect(obtenerContador()).toBe(5);
});
it("debe retornar un número", () => {
expect(typeof obtenerContador()).toBe("number");
});
});
describe("Reto 3: obtenerNombreCurso", () => {
it('debe retornar "Fundamentos de JavaScript"', () => {
expect(obtenerNombreCurso()).toBe("Fundamentos de JavaScript");
});
it("debe retornar un string", () => {
expect(typeof obtenerNombreCurso()).toBe("string");
});
});
describe("Reto 4: reasignarMensaje", () => {
it("debe retornar un objeto con inicial y final", () => {
const resultado = reasignarMensaje();
expect(resultado).toHaveProperty("inicial");
expect(resultado).toHaveProperty("final");
});
it('el valor inicial debe ser "hola"', () => {
expect(reasignarMensaje().inicial).toBe("hola");
});
it('el valor final debe ser "adiós"', () => {
expect(reasignarMensaje().final).toBe("adiós");
});
});
describe("Reto 5: calcularTotal", () => {
it("debe retornar un objeto con precioBase, descuento y total", () => {
const resultado = calcularTotal();
expect(resultado).toHaveProperty("precioBase");
expect(resultado).toHaveProperty("descuento");
expect(resultado).toHaveProperty("total");
});
it("precioBase debe ser 100", () => {
expect(calcularTotal().precioBase).toBe(100);
});
it("descuento debe ser 25 (reasignado)", () => {
expect(calcularTotal().descuento).toBe(25);
});
it("total debe ser 75", () => {
expect(calcularTotal().total).toBe(75);
});
});
describe("Reto 6: identificarTipos", () => {
it("debe identificar el tipo de edad como number", () => {
expect(identificarTipos().tipoEdad).toBe("number");
});
it("debe identificar el tipo de nombre como string", () => {
expect(identificarTipos().tipoNombre).toBe("string");
});
it("debe identificar el tipo de activo como boolean", () => {
expect(identificarTipos().tipoActivo).toBe("boolean");
});
});
describe("Reto 7: demostrarHoisting", () => {
it("debe retornar un objeto con antes y despues", () => {
const resultado = demostrarHoisting();
expect(resultado).toHaveProperty("antes");
expect(resultado).toHaveProperty("despues");
});
it("antes debe ser undefined (hoisting)", () => {
expect(demostrarHoisting().antes).toBeUndefined();
});
it('despues debe ser "Oscar"', () => {
expect(demostrarHoisting().despues).toBe("Oscar");
});
});
});