Skip to content

Commit 0532aba

Browse files
committed
main_test.js_test1
1 parent 7353f91 commit 0532aba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lab1/main_test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const test = require('node:test');
22
const assert = require('assert');
33
const { MyClass, Student } = require('./main');
44

5-
test("Test MyClass's addStudent", () => {
5+
test("Test MyClass's addStudent" , async () =>{
66
const myClass = new MyClass();
77
const student = new Student();
88
student.setName("Tingegg");
@@ -15,7 +15,7 @@ test("Test MyClass's addStudent", () => {
1515

1616
});
1717

18-
test("Test MyClass's getStudentById", () => {
18+
test("Test MyClass's getStudentById", async () => {
1919
const myClass = new MyClass();
2020
const student = new Student();
2121
student.setName("Bob");
@@ -28,17 +28,21 @@ test("Test MyClass's getStudentById", () => {
2828

2929
});
3030

31-
test("Test Student's setName", () => {
31+
test("Test Student's setName", async () => {
3232
const student = new Student();
3333
student.setName("Charlie");
3434
assert.strictEqual(student.getName(), "Charlie");
3535
student.setName(null);
3636
assert.strictEqual(student.getName(), '');
3737
});
3838

39-
test("Test Student's getName", () => {
39+
test("Test Student's getName", async () => {
40+
const myClass = new MyClass();
4041
const student = new Student();
4142
student.setName("David");
4243
assert.strictEqual(student.getName(), "David");
44+
student.setName("Eve");
45+
await myClass.addStudent(student);
46+
assert.strictEqual(myClass.students.length, 1);
4347
});
4448

0 commit comments

Comments
 (0)