From ad9bfacedd895976554216f6ad0d127e5bd62d6d Mon Sep 17 00:00:00 2001 From: Sun Date: Thu, 29 Feb 2024 14:18:44 +0800 Subject: [PATCH 1/4] doc: add title's description and branch warning in pr template --- .github/pull_request_template.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 78b908d9..1d79d8c9 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -7,9 +7,9 @@ -- [ ] A clear title +- [ ] A clear title (name your pr "[LAB{lab_number}] {your_student_id}") - [ ] A meaningful message for PR, as well as its commits -- [ ] From your specific branch (***not master***) merging to your branch +- [ ] From your specific branch (***not main or other's branch***) merging to your branch - [ ] Excluding any irrelevant files, such as binaries, text files, or dot files - [ ] Passing tests/CI - [ ] Add proper label for this PR From a5a9797bd7bc598c63163a29fca374837fd0ccc7 Mon Sep 17 00:00:00 2001 From: Sun Date: Thu, 29 Feb 2024 14:19:05 +0800 Subject: [PATCH 2/4] feat: remove badge requirement in lab1 --- lab1/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lab1/README.md b/lab1/README.md index f205b0b9..779166ca 100644 --- a/lab1/README.md +++ b/lab1/README.md @@ -6,8 +6,7 @@ In this lab, you will write unit tests for functions implemented in `main.js`. Y ## Requirement -1. Write test cases in `main_test.js` and achieve 100% code coverage. (90%) -2. Add a badge and make it show `passing` in `README.md` in the root folder. (10%) +1. Write test cases in `main_test.js` and achieve 100% code coverage. (100%) You can run `validate.sh` in your local to test if you satisfy the requirements. From 01554ce0d9f96bc7afbc80cb7cdfadb0610910df Mon Sep 17 00:00:00 2001 From: Sun Date: Thu, 29 Feb 2024 14:21:46 +0800 Subject: [PATCH 3/4] doc: add sample's link in pr template --- .github/pull_request_template.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 1d79d8c9..fa079b42 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,5 +1,8 @@ ## Description + + + --- From 3a3ec9c39bc74c709243d45fb5b086523f045688 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Feb 2024 15:39:25 +0800 Subject: [PATCH 4/4] coverage 100% --- lab1/main_test.js | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/lab1/main_test.js b/lab1/main_test.js index 74a716b4..af91d5f9 100644 --- a/lab1/main_test.js +++ b/lab1/main_test.js @@ -3,21 +3,35 @@ const assert = require('assert'); const { MyClass, Student } = require('./main'); test("Test MyClass's addStudent", () => { - // TODO - throw new Error("Test not implemented"); + const myClass = new MyClass(); + assert.equal(myClass.addStudent(69), -1); + const student = new Student(); + const name = "John"; + student.setName(name); + myClass.addStudent(student); }); test("Test MyClass's getStudentById", () => { - // TODO - throw new Error("Test not implemented"); + const myClass = new MyClass(); + const student = new Student(); + const name = "John"; + student.setName(name); + const id = myClass.addStudent(student); + assert.strictEqual(myClass.getStudentById(-1), null); + assert.strictEqual(myClass.getStudentById(50), null); + assert.strictEqual(myClass.getStudentById(id), student); }); test("Test Student's setName", () => { - // TODO - throw new Error("Test not implemented"); + const student = new Student(); + student.setName(69); + student.setName("John"); }); test("Test Student's getName", () => { - // TODO - throw new Error("Test not implemented"); + const student = new Student(); + const name = "John" + assert.equal(student.getName(), ''); + student.setName(name); + assert.strictEqual(student.getName(), name); }); \ No newline at end of file