Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*We need to import the Lecturer.js and Admin.js files to enable us test them accordingly*/
- const Lecturer = require("./Lecturer");
- const Admin = require("./Admin");
- /*Create some global variables*/
- var admin, lecturer1, lecturer2, timetable;
- /*create an admin object to enable us create lecturer objects*/
- test("create new admin user", function() {
- admin = new Admin("Admin1");
- expect(admin.name).toBe("Admin1");
- });
- /*Ensure that an Admin objet can actually create a lecturer object*/
- test("Admin can create new lecturer", function() {
- /*Returns: Lecturer {
- name: 'ogbodo Izu',
- role: 'Lecturer',
- department: 'mathematics',
- courses: [ 'mth' ],
- email: 'solomon@gmail.com',
- password: 'solomon',
- id: 1 } */
- lecturer1 = admin.createNewLecturer(
- "ogbodo Izu",
- "mathematics",
- ["mth"],
- "solomon@gmail.com",
- "solomon"
- );
- lecturer2 = admin.createNewLecturer(
- "Treasure ogbonna",
- "political science",
- ["pol212", "soc222"],
- "tressy@gmail.com",
- "tressy"
- );
- expect(lecturer1).toBeTruthy();
- });
- /*Return [ Course {
- title: 'Mth401',
- venue: 'AUD',
- startTime: '10am',
- endTime: '12pm',
- day: 'mon',
- userId: 1,
- id: 1,
- department: 'mathematics' },
- Course {
- title: 'Mth211',
- venue: 'AUD2',
- startTime: '8am',
- endTime: '10am',
- day: 'wed',
- userId: 1,
- id: 3,
- department: 'mathematics' } ]*/
- test("lecturer can create timetable", function() {
- timetable = lecturer1.createTimetable("Mth401", "AUD", "10am", "12pm", "mon");
- expect(timetable).toBeTruthy();
- });
- /*Test to see if any lecturer can read only there own timetables*/
- test("Lecturer can read only all timetables belonging to him/her", function() {
- lecturer1.createTimetable("Mth211", "AUD2", "8am", "10am", "wed");
- expect(lecturer1.readAllTimetables()).toBeTruthy();
- });
- /*Test to see if any lecturer can read only there own timetables by course title*/
- test("Lecturers can read their own timetables by course title", function() {
- expect(lecturer2.readTimetableByCourseTitle("Pol212")).toBeTruthy();
- });
- /*Test to see that another lecture*/
- test("Lecturer cannot read others timetables", function() {
- expect(lecturer1.readTimetableByCourseTitle("Pol212")).toBeFalsy();
- });
- /*Test to see if lecturer can read only there own timetables*/
- test("Lecturers can update their own timetables", function() {
- var timetableUpdate = ["Eng421", "LR66", "3pm", "5pm", "thursday"];
- expect(
- lecturer2.updateTimetable("Pol212", "4pm", "fri", timetableUpdate)
- ).toBeTruthy();
- });
- /*Test to see what happends when a lecturer object want to update timetable with one or more missing input*/
- test("Lecturers trying to update their own timetables with one or more update data not inputed", function() {
- var timetableUpdate = ["MTH302", "AUD", "3pm", "5pm"];
- expect(
- lecturer1.updateTimetable("Mth401", "10am", "mon", timetableUpdate)
- ).toBeTruthy();
- });
- /*Check if a lecturer can update their timetable*/
- test("Lecturers cannot update others timetable", function() {
- var timetableUpdate = ["Eng421", "LR66", "3pm", "5pm", "thursday"];
- expect(
- lecturer1.updateTimetable("Pol212", "4pm", "fri", timetableUpdate)
- ).toBeFalsy();
- });
- /*Test to see what happends when a lecturer object want to update timetable with one or more wrong input*/
- test("Lecturers trying to update their own timetables with one or more wrong needed data not inputed", function() {
- var timetableUpdate = ["Eng421", "LR66", "3pm", "5pm", "thursday"];
- expect(
- lecturer1.updateTimetable("Pol212", "4pm", timetableUpdate)
- ).toBeFalsy();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement