diff --git a/lab1/main_test.js b/lab1/main_test.js index 74a716b4..fedf0078 100644 --- a/lab1/main_test.js +++ b/lab1/main_test.js @@ -4,20 +4,51 @@ const { MyClass, Student } = require('./main'); test("Test MyClass's addStudent", () => { // TODO - throw new Error("Test not implemented"); + const myClass = new MyClass(); + const student = new Student(); + student.setName('Alex'); + + assert.strictEqual(myClass.addStudent(student), 0); + assert.strictEqual(myClass.students.length, 1); + assert.strictEqual(myClass.students[0], student); + // throw new Error("Test not implemented"); }); test("Test MyClass's getStudentById", () => { // TODO - throw new Error("Test not implemented"); + const myClass = new MyClass(); + const student1 = new Student(); + student1.setName("Alex"); + const student2 = new Student(); + student2.setName("Albert"); + myClass.addStudent(student1); + myClass.addStudent(student2); + + const retrieved_student1 = myClass.getStudentById(0); + const retrieved_student2 = myClass.getStudentById(1); + assert.strictEqual(retrieved_student1.getName(), "Alex"); + assert.strictEqual(retrieved_student2.getName(), "Albert"); + // throw new Error("Test not implemented"); }); test("Test Student's setName", () => { // TODO - throw new Error("Test not implemented"); + const student = new Student(); + + student.setName("Alex"); + + assert.strictEqual(student.getName(), "Alex"); + // throw new Error("Test not implemented"); }); test("Test Student's getName", () => { // TODO - throw new Error("Test not implemented"); + const student = new Student(); + + student.setName("Alex"); + + const name = student.getName(); + + assert.strictEqual(name, "Alex"); + // throw new Error("Test not implemented"); }); \ No newline at end of file