diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 78b908d9..fa079b42 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,5 +1,8 @@ ## Description + + + --- @@ -7,9 +10,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 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. 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