From 1201509bc9491b39cd5b0e2fd2933938c171e40e Mon Sep 17 00:00:00 2001 From: zbtion Date: Thu, 29 Feb 2024 22:01:47 +0800 Subject: [PATCH 1/4] test implementation --- lab1/main_test.js | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/lab1/main_test.js b/lab1/main_test.js index 74a716b4..b26d86f9 100644 --- a/lab1/main_test.js +++ b/lab1/main_test.js @@ -4,20 +4,48 @@ const { MyClass, Student } = require('./main'); test("Test MyClass's addStudent", () => { // TODO - throw new Error("Test not implemented"); + const myClass = new MyClass(); + const names = ["John", "Doe", "Jane", "Doe"]; + names.forEach(name => { + const student = new Student(); + student.setName(name); + assert.strictEqual(myClass.addStudent(student), myClass.students.length - 1); + }); + assert.strictEqual(myClass.addStudent({}), -1); + //throw new Error("Test not implemented"); }); test("Test MyClass's getStudentById", () => { // TODO - throw new Error("Test not implemented"); + const myClass = new MyClass(); + const names = ["John", "Doe", "Jane", "Doe"]; + names.forEach(name => { + const student = new Student(); + student.setName(name); + myClass.addStudent(student); + assert.strictEqual(myClass.getStudentById(myClass.students.length - 1).getName(), name); + }); + assert.strictEqual(myClass.getStudentById(-1), null); + assert.strictEqual(myClass.getStudentById(myClass.students.length), null); + //throw new Error("Test not implemented"); }); test("Test Student's setName", () => { // TODO - throw new Error("Test not implemented"); + const student = new Student(); + student.setName("John"); + assert.strictEqual(student.getName(), "John"); + student.setName(123); + assert.strictEqual(student.getName(), "John"); + //throw new Error("Test not implemented"); }); test("Test Student's getName", () => { // TODO - throw new Error("Test not implemented"); + const student = new Student(); + assert.strictEqual(student.getName(), ""); + student.setName("John"); + assert.strictEqual(student.getName(), "John"); + + //throw new Error("Test not implemented"); }); \ No newline at end of file From fe473a0061cd8cba58f32d6f140c4a296bb30aa0 Mon Sep 17 00:00:00 2001 From: zbtion Date: Thu, 29 Feb 2024 22:55:14 +0800 Subject: [PATCH 2/4] changee pr to push --- .github/workflows/lab1.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/lab1.yml b/.github/workflows/lab1.yml index 62e939c5..7adeef42 100644 --- a/.github/workflows/lab1.yml +++ b/.github/workflows/lab1.yml @@ -1,8 +1,6 @@ name: lab1 -on: - pull_request: - types: [labeled] +on: [push] jobs: build: From 087bd9f3467220e5ba172422ce18af899bb3483f Mon Sep 17 00:00:00 2001 From: zbtion Date: Thu, 29 Feb 2024 22:56:55 +0800 Subject: [PATCH 3/4] delete the label --- .github/workflows/lab1.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/lab1.yml b/.github/workflows/lab1.yml index 7adeef42..ff565cf8 100644 --- a/.github/workflows/lab1.yml +++ b/.github/workflows/lab1.yml @@ -4,7 +4,6 @@ on: [push] jobs: build: - if: ${{ github.event.label.name == 'lab1' }} runs-on: ${{ matrix.os }} strategy: matrix: From 85b2ffb6f92f65f315e358d11377d55a208a4e55 Mon Sep 17 00:00:00 2001 From: zbtion Date: Thu, 29 Feb 2024 23:13:19 +0800 Subject: [PATCH 4/4] reset the yml file --- .github/workflows/lab1.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lab1.yml b/.github/workflows/lab1.yml index ff565cf8..137fba05 100644 --- a/.github/workflows/lab1.yml +++ b/.github/workflows/lab1.yml @@ -1,9 +1,12 @@ name: lab1 -on: [push] +on: + pull_request: + types: [labeled] jobs: build: + if: ${{ github.event.label.name == 'lab1' }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -21,4 +24,4 @@ jobs: run: | echo "cd lab1" cd lab1 - ./validate.sh + ./validate.sh \ No newline at end of file