@@ -2,7 +2,7 @@ const test = require('node:test');
2
2
const assert = require ( 'assert' ) ;
3
3
const { MyClass, Student } = require ( './main' ) ;
4
4
5
- test ( "Test MyClass's addStudent" , ( ) => {
5
+ test ( "Test MyClass's addStudent" , async ( ) => {
6
6
const myClass = new MyClass ( ) ;
7
7
const student = new Student ( ) ;
8
8
student . setName ( "Tingegg" ) ;
@@ -15,7 +15,7 @@ test("Test MyClass's addStudent", () => {
15
15
16
16
} ) ;
17
17
18
- test ( "Test MyClass's getStudentById" , ( ) => {
18
+ test ( "Test MyClass's getStudentById" , async ( ) => {
19
19
const myClass = new MyClass ( ) ;
20
20
const student = new Student ( ) ;
21
21
student . setName ( "Bob" ) ;
@@ -28,17 +28,21 @@ test("Test MyClass's getStudentById", () => {
28
28
29
29
} ) ;
30
30
31
- test ( "Test Student's setName" , ( ) => {
31
+ test ( "Test Student's setName" , async ( ) => {
32
32
const student = new Student ( ) ;
33
33
student . setName ( "Charlie" ) ;
34
34
assert . strictEqual ( student . getName ( ) , "Charlie" ) ;
35
35
student . setName ( null ) ;
36
36
assert . strictEqual ( student . getName ( ) , '' ) ;
37
37
} ) ;
38
38
39
- test ( "Test Student's getName" , ( ) => {
39
+ test ( "Test Student's getName" , async ( ) => {
40
+ const myClass = new MyClass ( ) ;
40
41
const student = new Student ( ) ;
41
42
student . setName ( "David" ) ;
42
43
assert . strictEqual ( student . getName ( ) , "David" ) ;
44
+ student . setName ( "Eve" ) ;
45
+ await myClass . addStudent ( student ) ;
46
+ assert . strictEqual ( myClass . students . length , 1 ) ;
43
47
} ) ;
44
48
0 commit comments