Skip to content

Commit

Permalink
test implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
zbtion committed Feb 29, 2024
1 parent 033f080 commit e449f81
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,48 @@ const { MyClass, Student } = require('./main');

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
const myClass = new MyClass();
const names = ["John", "Doe", "Jane", "Doe"];
names.forEach(name => {
const student = new Student();
student.setName(name);
assert.strictEqual(myClass.addStudent(student), myClass.students.length - 1);
});
assert.strictEqual(myClass.addStudent({}), -1);
//throw new Error("Test not implemented");
});

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
const myClass = new MyClass();
const names = ["John", "Doe", "Jane", "Doe"];
names.forEach(name => {
const student = new Student();
student.setName(name);
myClass.addStudent(student);
assert.strictEqual(myClass.getStudentById(myClass.students.length - 1).getName(), name);
});
assert.strictEqual(myClass.getStudentById(-1), null);
assert.strictEqual(myClass.getStudentById(myClass.students.length), null);
//throw new Error("Test not implemented");
});

test("Test Student's setName", () => {
// TODO
throw new Error("Test not implemented");
const student = new Student();
student.setName("John");
assert.strictEqual(student.getName(), "John");
student.setName(123);
assert.strictEqual(student.getName(), "John");
//throw new Error("Test not implemented");
});

test("Test Student's getName", () => {
// TODO
throw new Error("Test not implemented");
const student = new Student();
assert.strictEqual(student.getName(), "");
student.setName("John");
assert.strictEqual(student.getName(), "John");

//throw new Error("Test not implemented");
});

0 comments on commit e449f81

Please sign in to comment.