-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathmain_test.js
53 lines (47 loc) · 1.42 KB
/
main_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const test = require('node:test');
const assert = require('assert');
const { MyClass, Student } = require('./main');
const myclass = new MyClass;
test("Test MyClass's addStudent", () => {
// TODO
assert.equal(-1, myclass.addStudent('Oops'));
const student = new Student;
const name = 'Kiwi'
student.setName(name);
assert.equal(0, myclass.addStudent(student));
return;
// throw new Error("Test not implemented");
});
test("Test MyClass's getStudentById", () => {
// TODO
assert.equal(null, myclass.getStudentById(-3));
assert.equal(null, myclass.getStudentById(10));
const student = new Student;
const name = 'Kiwi'
student.setName(name);
const id = myclass.addStudent(student);
assert.equal(student, myclass.getStudentById(id));
return;
// throw new Error("Test not implemented");
});
test("Test Student's setName", () => {
// TODO
const student = new Student;
student.setName(123);
assert.equal(undefined, student.name);
const name = 'Kiwi'
student.setName(name);
assert.equal(name, student.name);
return;
// throw new Error("Test not implemented");
});
test("Test Student's getName", () => {
// TODO
const student = new Student;
assert.equal('', student.getName());
const name = 'Kiwi'
student.setName(name);
assert.equal(name, student.getName());
return;
// throw new Error("Test not implemented");
});