Created
March 14, 2022 21:45
-
-
Save zt4ff/1eee86671a63216847ce0c415d17e9ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.test.js | |
const assert = require("assert"); | |
const StudentManagement = require("./index"); | |
describe("Student Management Module", () => { | |
let testClass; | |
before(() => { | |
testClass = new StudentManagement(["Abel", "Ben", "Cain"]); | |
}); | |
it("should have three students", () => { | |
assert.equal(testClass.getStudent().length, 3); | |
}); | |
it("adds new students and confirm that the new students are added", () => { | |
testClass.add("Daniel", "Evelyn"); | |
assert.equal(testClass.getStudent().length, 5); | |
}); | |
it("checks the content of the students list and verify it", () => { | |
const expectedStudentList = [ | |
{ id: 1, name: "Abel", performance: null }, | |
{ id: 2, name: "Ben", performance: null }, | |
{ id: 3, name: "Cain", performance: null }, | |
{ id: 4, name: "Daniel", performance: null }, | |
{ id: 5, name: "Evelyn", performance: null }, | |
]; | |
assert.deepEqual(testClass.getStudent(), expectedStudentList); | |
}); | |
it("score Abel and confirm that Abel is scored", () => { | |
testClass.score(1, 50); | |
const abelStudentObject = [{ id: 1, name: "Abel", performance: 50 }] | |
assert.deepEqual(testClass.getStudent(1), abelStudentObject) | |
assert.deepEqual(testClass.getStudent("Abel"), abelStudentObject) | |
}); | |
it("should verity there is an error is score is greater than 100", () => { | |
assert.throws(() => { | |
testClass.score(1, 105); | |
}, Error) | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment