Skip to content

Commit 8fda5a0

Browse files
committed
unit test addStudent
1 parent 75d07e0 commit 8fda5a0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lab1/main_test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
const test = require('node:test');
22
const assert = require('assert');
33
const { MyClass, Student } = require('./main');
4+
const exp = require('constants');
45

56
test("Test MyClass's addStudent", () => {
67
// TODO
7-
throw new Error("Test not implemented");
8+
const myClass = new MyClass();
9+
const student = new Student();
10+
const newStudentId = myClass.addStudent(student);
11+
assert.strictEqual(newStudentId, 0);
12+
assert.strictEqual(myClass.students.length, 1);
13+
assert.strictEqual(myClass.students[0], student);
14+
15+
// throw new Error("Test not implemented");
816
});
917

1018
test("Test MyClass's getStudentById", () => {
1119
// TODO
12-
throw new Error("Test not implemented");
20+
// throw new Error("Test not implemented");
1321
});
1422

1523
test("Test Student's setName", () => {
1624
// TODO
17-
throw new Error("Test not implemented");
25+
// throw new Error("Test not implemented");
1826
});
1927

2028
test("Test Student's getName", () => {

0 commit comments

Comments
 (0)