Skip to content

Commit

Permalink
Merge pull request #14 from Cutiemango/312551068
Browse files Browse the repository at this point in the history
[LAB1] 312551068
  • Loading branch information
TaiYou-TW authored Mar 7, 2024
2 parents 2d41d26 + 318b344 commit 4acc6f8
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lab1/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ const test = require('node:test');
const assert = require('assert');
const { MyClass, Student } = require('./main');

const myClass = new MyClass();

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

test("Test MyClass's getStudentById", () => {
// TODO
throw new Error("Test not implemented");
assert.strictEqual(myClass.getStudentById(0) instanceof Student, true);
assert.strictEqual(myClass.getStudentById(1), null);
});

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

student.setName(null);
assert.strictEqual(student.getName(), 'John');
});

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

assert.strictEqual(name, '');
});

0 comments on commit 4acc6f8

Please sign in to comment.