@@ -4,20 +4,38 @@ const { MyClass, Student } = require('./main');
4
4
5
5
test ( "Test MyClass's addStudent" , ( ) => {
6
6
// TODO
7
- throw new Error ( "Test not implemented" ) ;
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");
8
13
} ) ;
9
14
10
15
test ( "Test MyClass's getStudentById" , ( ) => {
11
16
// TODO
12
- throw new Error ( "Test not implemented" ) ;
17
+ const myClass = new MyClass ( ) ;
18
+ const student1 = new Student ( "John" ) ;
19
+ const student2 = new Student ( "Alice" ) ;
20
+ const student3 = new Student ( "Bob" ) ;
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");
13
27
} ) ;
14
28
15
29
test ( "Test Student's setName" , ( ) => {
16
30
// TODO
17
- throw new Error ( "Test not implemented" ) ;
31
+ const student = new Student ( "John" ) ;
32
+ student . setName ( "Alice" ) ;
33
+ assert . strictEqual ( student . getName ( ) , "Alice" ) ;
18
34
} ) ;
19
35
20
36
test ( "Test Student's getName" , ( ) => {
21
37
// TODO
22
- throw new Error ( "Test not implemented" ) ;
23
- } ) ;
38
+ const student = new Student ( "John" ) ;
39
+ assert . strictEqual ( student . getName ( ) , "John" ) ;
40
+ //throw new Error("Test not implemented");
41
+ } ) ;
0 commit comments