@@ -3,60 +3,39 @@ const assert = require('assert');
3
3
const { MyClass, Student } = require ( './main' ) ;
4
4
5
5
test ( "Test MyClass's addStudent" , ( ) => {
6
- const myClass = new MyClass ( ) ;
7
- const student = new Student ( ) ;
8
-
9
- // Test adding a student
10
- myClass . addStudent ( student ) ;
11
- assert . strictEqual ( myClass . students . length , 1 ) ;
12
- assert . strictEqual ( myClass . students [ 0 ] , student ) ;
13
-
14
- // Test adding multiple students
15
- const student2 = new Student ( ) ;
16
- const student3 = new Student ( ) ;
17
- myClass . addStudent ( student2 ) ;
18
- myClass . addStudent ( student3 ) ;
19
- assert . strictEqual ( myClass . students . length , 3 ) ;
6
+ // TODO
7
+ const myClass = new MyClass ( ) ;
8
+ const student = new Student ( "John" ) ;
9
+ myClass . addStudent ( student ) ;
10
+ assert . strictEqual ( myClass . students . length , 1 ) ;
11
+ assert . strictEqual ( myClass . students [ 0 ] , student ) ;
12
+ //throw new Error("Test not implemented");
20
13
} ) ;
21
14
22
15
test ( "Test MyClass's getStudentById" , ( ) => {
23
- const myClass = new MyClass ( ) ;
24
- const student1 = new Student ( ) ;
25
- const student2 = new Student ( ) ;
26
- const student3 = new Student ( ) ;
27
- myClass . addStudent ( student1 ) ;
28
- myClass . addStudent ( student2 ) ;
29
- myClass . addStudent ( student3 ) ;
30
-
31
- // Test getting a student by ID
32
- const foundStudent = myClass . getStudentById ( 1 ) ;
33
- assert . strictEqual ( foundStudent , student2 ) ;
34
-
35
- // Test getting a non-existing student by ID
36
- const nonExistingStudent = myClass . getStudentById ( 5 ) ;
37
- assert . strictEqual ( nonExistingStudent , null ) ;
16
+ // TODO
17
+ const myClass = new MyClass ( ) ;
18
+ const student1 = new Student ( "John" ) ;
19
+ const student2 = new Student ( "Jane" ) ;
20
+ const student3 = new Student ( "Doe" ) ;
21
+ myClass . addStudent ( student1 ) ;
22
+ myClass . addStudent ( student2 ) ;
23
+ myClass . addStudent ( student3 ) ;
24
+ const foundStudent = myClass . getStudentById ( student2 . id ) ;
25
+ assert . strictEqual ( foundStudent , student2 ) ;
26
+ //throw new Error("Test not implemented");
38
27
} ) ;
39
28
40
29
test ( "Test Student's setName" , ( ) => {
41
- const student = new Student ( ) ;
42
-
43
- // Test setting a valid name
44
- student . setName ( "John" ) ;
45
- assert . strictEqual ( student . getName ( ) , "John" ) ;
46
-
47
- // Test setting an invalid name
48
- student . setName ( 123 ) ; // Passing a number instead of a string
49
- assert . strictEqual ( student . getName ( ) , "" ) ; // Name should remain unchanged
30
+ // TODO
31
+ const student = new Student ( "John" ) ;
32
+ student . setName ( "Smith" ) ;
33
+ assert . strictEqual ( student . getName ( ) , "Smith" ) ;
50
34
} ) ;
51
35
52
36
test ( "Test Student's getName" , ( ) => {
53
- const student = new Student ( ) ;
54
-
55
- // Test getting name when name is set
56
- student . setName ( "John" ) ;
57
- assert . strictEqual ( student . getName ( ) , "John" ) ;
58
-
59
- // Test getting name when name is not set
60
- assert . strictEqual ( student . getName ( ) , "" ) ; // Should return an empty string
37
+ // TODO
38
+ const student = new Student ( "John" ) ;
39
+ assert . strictEqual ( student . getName ( ) , "John" ) ;
40
+ //throw new Error("Test not implemented");
61
41
} ) ;
62
-
0 commit comments