Skip to content

Commit

Permalink
test(curso): utilities methods
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisCusihuaman committed Aug 12, 2023
1 parent d2a7057 commit 58d5900
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
31 changes: 30 additions & 1 deletion src/analytics/curso.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ describe("Curso", () => {

expect(promedios).toEqual(expected);
});
it("get_docentes should return the list of docentes", () => {
let docente1 = new Docente("John");
let docente2 = new Docente("Alice");
curso.agregar_docente(docente1);
curso.agregar_docente(docente2);
const docentes = curso.get_docentes();
expect(docentes).toEqual([docente1, docente2]);
});

it("get_docentes_str should return a formatted string of docente names", () => {
let docente1 = new Docente("John");
let docente2 = new Docente("Alice");
curso.agregar_docente(docente1);
curso.agregar_docente(docente2);
const docentesStr = curso.get_docentes_str();
expect(docentesStr).toEqual("John-Alice");
});

it("get_docentes_str should truncate names that are too long", () => {
let docente1 = new Docente("John");
let docente2 = new Docente("Alice");
const longNameDocente = new Docente("ThisIsAVeryLongDocenteNameThatExceedsFiftyCharacters");
curso.agregar_docente(docente1);
curso.agregar_docente(docente2);
curso.agregar_docente(longNameDocente);

const docentesStr = curso.get_docentes_str();
expect(docentesStr).toEqual("John-Alice-ThisIsAVeryLongDocenteNameThatExceedsFi...");
});
});

describe("Docente", () => {
Expand Down Expand Up @@ -123,7 +152,7 @@ describe("Docente", () => {
// Since there are no valoraciones, the mean should be NaN
expect(valoraciones["asistencia"]).toBeUndefined();
});
// Add more test cases for other methods

});

describe("Materia", () => {
Expand Down
4 changes: 0 additions & 4 deletions src/analytics/curso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export class Curso {
return this.docentes.find(doc => doc.get_nombre() === d) || null;

Check failure on line 25 in src/analytics/curso.ts

View workflow job for this annotation

GitHub Actions / lint-format-test

'Docente' was used before it was defined
}

get_index(): string {
return this.id.toString();
}

get_docentes(): Docente[] {
return this.docentes;
}
Expand Down

0 comments on commit 58d5900

Please sign in to comment.