Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LAB1] 313553034 #127

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,47 @@ const assert = require('assert');
const { MyClass, Student } = require('./main');

test("Test MyClass's addStudent", () => {
// TODO
throw new Error("Test not implemented");
const Class = new MyClass();
const student = new Student();
const id = Class.addStudent(student);
assert.strictEqual(id, 0);
assert.strictEqual(Class.addStudent({}), -1);
});

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

const id = Class.addStudent(student);
const StudentID = Class.getStudentById(id);

assert.strictEqual(StudentID.getName(), "John");
assert.strictEqual(Class.getStudentById(-1), null);
assert.strictEqual(Class.getStudentById(999), null);

});

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

student.setName("John");
const StudentName = student.getName();


assert.strictEqual(StudentName, "John");

});

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

// "" in default
assert.strictEqual(student.getName(), "");

student.setName("John");
const StudentName = student.getName();
assert.strictEqual(StudentName, "John");
});